Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor will not run without Sudo?

On OSX Yosemite and the latest version of meteor (1.0.1), no matter how many times I uninstall and reinstall it, I can't seem to get it running without sudo. My user account is an administrator account. But meteor refuses to run without sudo. The errors I'm getting are all:

-bash: meteor: command not found

I've seen a few posts on here with similar problems. I've tried repairing disk permissions with disk utility. I've tried:

sudo chown -R $myUsername /usr/local/bin/meteor

I'm not sure what else I can do, because it seems to be a permissions issue. Does anyone have any suggestions?

Additional info that might help:

$ sudo which meteor
/usr/local/bin/meteor
$ sudo ls -l /usr/local/bin/meteor
-rwxrwxrwx 1 root wheel 3528 Dec 18 23:14 /usr/local/bin/meteor
$ ls -ld /usr/local/bin
drwx------ 6 502 wheel 204 Dec 18 23:14 /usr/local/bin

By the way, ls -l /usr/local/bin/meteor only works with sudo.

like image 211
Rashad Nasir Avatar asked Dec 19 '14 02:12

Rashad Nasir


2 Answers

After we clarified the permissions of the meteor executable and its base directory, the problem became quite clear:

  • The Meteor binary is located in /usr/local/bin/meteor
  • Your user didn't have permission to the directory /usr/local/bin

The steps to resolve:

  1. Add permission on the base directory: sudo chmod +rx /usr/local/bin
  2. If necessary, add the base directory to PATH: PATH=$PATH:/usr/local/bin

For future reference:

  • When you get this kind of error: -bash: XYZ: command not found
    • The first thing to check is find the absolute path of XYZ, for example /path/to/XYZ
    • Try to run with the absolute path /path/to/XYZ
  • If running with /path/to/XYZ gives -bash: /path/to/XYZ: Permission denied that means you have a problem with permissions on the file and/or directories:
    • You need read and exec permission on the file itself: sudo chmod +rx /path/to/XYZ
    • You need exec permission on all path elements leading up to the file: sudo chmod +x /path /path/to
  • After fixing permission issues, running with /path/to/XYZ should work
  • After fixing permission issues, if running with XYZ (without full path) still doesn't work, that means /path/to is not on your PATH. Fix with PATH=$PATH:/path/to

Note: the above sudo chmod commands give permissions (read and exec) to all users: owner + group + other. In the case of the OP (and in most common cases), this is perfectly fine. In situations with more sophisticated permission setup, you might need to be more specific, and use g+rx instead of +rx.

(for the record)

If it works with sudo, and without sudo you get command not found, that means that meteor is on the PATH for root but not for your user. To make it work for your user, you need to find the path to meteor and add it to your user's PATH. For example:

  1. Become root with sudo su -
  2. Find the path of meteor, run command: which meteor
  3. Logout from root (Control-D) to return to your user
  4. Add the base directory to PATH, for example if earlier which meteor gave you /usr/local/bin/meteor, then do this: PATH=$PATH:/usr/local/bin

After this, it should work with your user. To make it "permanent", add the last step in your ~/.bashrc.

If this still doesn't work, then perhaps your user doesn't have the execute permission on the file. Fix that with this command:

sudo chmod +x /usr/local/bin/meteor

From your comments it also seems your user doesn't have permission on the /usr/local/bin directory itself. Fix that with this command:

sudo chmod +rx /usr/local/bin
like image 78
janos Avatar answered Oct 10 '22 06:10

janos


Shouldn't need an admin account to run it, standard user account works fine. You can locate the meteor file by typing which meteor. It will tell you what file is being used to execute.

Try removing the .meteor folder in your home directory, something like rm -rf ~/.meteor and the script from the bin folder rm /usr/local/bin/meteor or rm 'which meteor' (speech marks there are the ones above ~)

And then reinstall meteor without sudo using the curl https://install.meteor.com/ | sh command.

Should hopefully install with all the correct permissions...

like image 45
Aaron Avatar answered Oct 10 '22 07:10

Aaron