Getting error: /usr/bin/env: ruby: No such file or directory


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Getting error: /usr/bin/env: ruby: No such file or directory
# 1  
Old 09-03-2017
RedHat Getting error: /usr/bin/env: ruby: No such file or directory

Hi,

I installed ruby using rvm with root user on Linux.

Now i m trying the below command as a non root user [webadmin] with sudo privileges.

Code:
sudo /usr/local/rvm/rubies/ruby-2.2.5/bin/gem install passenger

I get the below error:

Quote:
/usr/bin/env: ruby: No such file or directory
I had even reset the path for both gem as well as ruby as you can see below but dont know why does it not reference.

Code:
$ sudo gem install passenger
sudo: gem: command not found
$ echo $PATH
/usr/local/rvm/rubies/ruby-2.2.5/bin:/usr/local/rvm/gems/ruby-2.2.5/bin:/usr/local/rvm/gems/ruby-2.2.5@global/bin:/usr/local/rvm/rubies/ruby-2.2.5/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/rvm/bin:/home/serviceusers/webadmin/.local/bin:/home/serviceusers/webadmin/bin


$ ls -ltr /usr/local/rvm/rubies/ruby-2.2.5/bin/gem
-rwxrwxr-x 1 root root 546 Aug 31 07:01 /usr/local/rvm/rubies/ruby-2.2.5/bin/gem
$ ls -ltr /usr/local/rvm/rubies/ruby-2.2.5/bin/ruby
-rwxrwxr-x 1 root root 138584 Aug 31 07:00 /usr/local/rvm/rubies/ruby-2.2.5/bin/ruby



The same command works with root user.

/usr/bin/env file is not even readable using vi editor.

What should i do to resolve this error.

Last edited by mohtashims; 09-03-2017 at 07:01 AM..
# 2  
Old 09-03-2017
1. become root
2. type the command 'which ruby'

If it fails then you have PATH variable problem.
If it returns a value, then check each and every directory in the result. Each directory has to have at least execute for other.
Or:
Code:
chmod +x directory_name

After that try running
Code:
which ruby

as another user. Make sure the PATH is correct. For all users on the system.
# 3  
Old 09-03-2017
Hammer & Screwdriver

Tried your suggestions but still it does not work.

Please see the output below.

Code:
[root@development temp1]# which ruby
/usr/local/rvm/rubies/ruby-2.2.5/bin/ruby

[root@development temp1]# which gem
/usr/local/rvm/rubies/ruby-2.2.5/bin/gem

[root@development temp1]# ls -ltrd /usr
drwxr-xr-x 13 root root 4096 Jul 25 23:23 /usr
[root@development temp1]# ls -ltrd /usr/local
drwxr-xr-x 22 root root 4096 Aug 31 06:36 /usr/local
[root@development temp1]# chmod -R 775 /usr/local/rvm
[root@development temp1]# exit
exit

[webadmin@development temp1]$ sudo gem install passenger
sudo: gem: command not found

[webadmin@development temp1]$ echo $PATH
/usr/local/rvm/rubies/ruby-2.2.5/bin:/usr/local/rvm/gems/ruby-2.2.5/bin:/usr/local/rvm/gems/ruby-2.2.5@global/bin:/usr/local/rvm/rubies/ruby-2.2.5/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/rvm/bin:/home/serviceusers/webadmin/.local/bin:/home/serviceusers/webadmin/bin

Not sure what am i missing !!

Last edited by mohtashims; 09-03-2017 at 10:20 AM..
# 4  
Old 09-03-2017
There has to be something wrong with permissions (ACL's) on directories or there is an unprintable character in the PATH variable. Or PATH for the two users does not match.

Also try
Code:
sudo echo $PATH | cat -v

Also note:
Your
Code:
echo $PATH

is for another user in your example, not necessarily the one you get the one you get with sudo.
# 5  
Old 09-03-2017
RedHat

Quote:
Originally Posted by jim mcnamara
There has to be something wrong with permissions (ACL's) on directories or there is an unprintable character in the PATH variable. Or PATH for the two users does not match.

Also try
Code:
sudo echo $PATH | cat -v

Also note:
Your
Code:
echo $PATH

is for another user in your example, not necessarily the one you get the one you get with sudo.
3
Sorry but no luck.

Please see the output below:

Code:
[webadmin@development temp1]$ sudo echo $PATH | cat -v
/usr/local/rvm/rubies/ruby-2.2.5/bin:/usr/local/rvm/gems/ruby-2.2.5/bin:/usr/local/rvm/gems/ruby-2.2.5@global/bin:/usr/local/rvm/rubies/ruby-2.2.5/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/rvm/bin:/home/serviceusers/webadmin/.local/bin:/home/serviceusers/webadmin/bin

# 6  
Old 09-03-2017
Did you check ACL's?

Edit: getfacl command does this.

Last edited by jim mcnamara; 09-04-2017 at 12:10 AM..
# 7  
Old 09-04-2017
Is your PATH variable exported? Try
Code:
export PATH

and try again.

Andrew
This User Gave Thanks to apmcd47 For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Discussion: use "/usr/bin/env" or not

Hi. In thread https://www.unix.com/shell-programming-and-scripting/265878-date-format-problem.html , Aia and I were discussing the usefulness of using #!/usr/bin/env bash (or ksh, or perl, or ...) as the shebang line. The exchange was good, but it was getting beyond the scope or the thread, so I... (4 Replies)
Discussion started by: drl
4 Replies

2. Shell Programming and Scripting

/usr/bin/scp error

I have this scp script running, /usr/bin/scp -r /cerner/mgr --exclude-from=/atg/move_exclude.dat 102.126.112.68:/cerner but am getting an error: --exclude-from=/atg/move_exclude.dat: No such file or directory I am wondering if the syntax is incorrect... I also have additional... (3 Replies)
Discussion started by: Daniel Gate
3 Replies

3. UNIX and Linux Applications

/usr/bin/ld: cannot find -lz error

I am installing lxml module for python on redhat I have installed libxml2 already. When I run for libxslt: ./configure --prefix=libxslt_folder --with-libxml-prefix=libxml2_folder It is ok the I run : make I have error: /usr/bin/ld: cannot find -lz collect2: ld returned 1 exit status I... (4 Replies)
Discussion started by: AIX_30
4 Replies

4. OS X (Apple)

When to use /Users/m/bin instead of /usr/local/bin (& whats the diff?)?

Q1. I understand that /usr/local/bin means I can install/uninstall stuff in here and have any chance of messing up my original system files or effecting any other users. I created this directory myself. But what about the directory I didn't create, namely /Users/m/bin? How is that directory... (1 Reply)
Discussion started by: michellepace
1 Replies

5. Shell Programming and Scripting

!/usr/bin/ksh error

Usually we use !/usr/bin/ksh at the start of the script.But if I am having this stuff in the scripts and calling one script from other its not working.What may be the reason behind it ? xyz.ksh #!/usr/bin/ksh echo "Hi" abc.ksh #!/usr/bin/ksh echo "I am fine" ksh xyz.ksh Its... (4 Replies)
Discussion started by: dr46014
4 Replies

6. UNIX for Advanced & Expert Users

#!/usr/bin/env : perl no such file or directory

hi i have some perl scripts with shebang line as (#! /usr/bin/env perl ) instead of actual absolute path of perl ( i know why its that way ) everything works fine from command line , the problem is when i am trying to run those scripts from web ( local web tool ) it throws error as /usr/bin/env :... (6 Replies)
Discussion started by: zedex
6 Replies

7. AIX

losing /usr/bin directory

I need help figuring out why I lose /usr/bin directory sometimes it goes down 3-4 times a day and I have to link them back using ln - /usr/bin bin I cannot figure out why this is happenning (23 Replies)
Discussion started by: smatherly
23 Replies

8. AIX

nim mksysb error :/usr/bin/savevg[33]: 1016,07: syntax error

-------------------------------------------------------------------------------- Hello, help me please. I am trying to create a mksysb bakup using nim. I am geting this error, how to correct it ? : Command : failed stdout: yes stderr: no... (9 Replies)
Discussion started by: astjen
9 Replies

9. UNIX for Dummies Questions & Answers

/bin/sh: /usr/bin/vi: No such file or directory when doing crontab

I just set up an ftp server with Red Hat 5.2. I am doing the work, I'm baby stepping, but it seems like every step I get stuck. Currently, I'm trying to set up a crontab job, but I'm getting the following message: /bin/sh: /usr/bin/vi: No such file or directory. I see that vi exists in /bin/vi,... (3 Replies)
Discussion started by: kwalter
3 Replies
Login or Register to Ask a Question