I made a simple program in ruby. The file has the shebang at the top and it is executable. When I run it (./parser.rb), it works.
I then created a symlink using ln -s parser.rb refs.
I then moved this symlink to /usr/local/bin. I restarted my terminal and ran refs, this gave me the following message:
zsh: command not found: refs I cheched my path variable:
jonaseveraert@MacBook-Air-van-Jonas bin % echo $PATH /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:/Users/jonaseveraert/.cargo/bin So that seems fine. I then went into the directory /usr/local/bin looked for the file:
jonaseveraert@MacBook-Air-van-Jonas bin % ls -l | grep refs lrwxr-xr-x@ 1 jonaseveraert staff 9 25 jan 14:14 refs.rb -> parser.rb So, the file is there, but running it inside of the directory gives me:
jonaseveraert@MacBook-Air-van-Jonas bin % ./refs zsh: no such file or directory: ./refs Is there anything I'm forgetting here? I can't seem to find an answer to this.
21 Answer
I have found the solution here. The problem was that I made the symlink inside of the same directory as parser.rb and then moved it to /usr/local/bin
When running
jonaseveraert@MacBook-Air-van-Jonas bin % ls -l | grep refs lrwxr-xr-x@ 1 jonaseveraert staff 9 25 jan 14:14 refs.rb -> parser.rb It shows that refs.rb is pointing to parser.rb in the same directory, but it's parser.rb that isn't there (because it's in another directory).
So, I executed /Users/jonaseveraert/Documents/projects/academic/parser/parser.rb refs inside of /usr/local/bin and now:
jonaseveraert@MacBook-Air-van-Jonas bin % ls -l refs lrwxr-xr-x 1 jonaseveraert admin 65 25 jan 15:36 refs -> /Users/jonaseveraert/Documents/projects/academic/parser/parser.rb The file is now pointing to the right file and can be executed using refs.