I am using ubunutu natty narwhal.I had installed ruby,rails,rvm etc.. sometime back and everything was running peacefully.Recently i tried to execute "rails -v" on the command line i get this frustrating error.
roger#roger-Inspiron-1545:~$ rails -v
bash: /home/roger/.rvm/gems/ruby-1.9.2-p180/bin/rails: /home/roger/.rvm/rubies/ruby- 1.9.2-p180/bin/ruby:
bad interpreter: Permission denied
I also get this error for other rails commands i execute
Can someone let me know what the problem is and how i can fix this.
Update:Whereis ruby gives me the this
roger#roger-Inspiron-1545:~$ whereis ruby
ruby: /usr/bin/ruby /usr/bin/ruby1.8 /usr/lib/ruby /usr/share/man/man1/ruby.1.gz
Thanks
run:
ls -l /home/roger/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
The first few characters of the entry should be "-rwx" and you should see your own username as the owner. If you don't see at least the "r" and the "x", run
chmod 755 /home/roger/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
to give the owner read/write/exec and everyone else read/execute.
If you aren't the owner, you'll need to do "sudo chown" to fix that.
I suspect that there's a bigger underlying problem though. If you have other ruby versions installed, switch to them in rvm, type "which ruby" and run "ls -l" on them as well.
Did you do a restore from backup recently? Maybe the permissions weren't correctly restored. Or did you run some kind of script that might've been too aggressive in changing owner or permissions? Or maybe you accidentally did a chmod or chown?
Related
I struggled for hours trying to have Assetic with Sass and Compass working on my production server.
The error is:
sh: 1: /root/.rbenv/shims/ruby: Permission denied
This is because my rbenv instalation is under the /root directory so Assetic doesn't have the permision to use it.
I've checked similar issues:
"Rbenv permission denied issue"
"rbenv: Permission Denied"
"Should rbenv be installed system-wide, or at a user level?"
but they didn't help.
I'm using Apache so I guess the default user is "www-data".
As explained in one of the above questions, I tried to grant www-data the permission in /root but either this didn't work or I did it wrong.
sudo chown -R www-data ~/.rbenv
This is the complete error:
[exception] 500 | Internal Server Error | Assetic\Exception\FilterException
[message] An error occurred while running:
'/root/.rbenv/shims/ruby' '/usr/local/bin/compass' 'compile' '/var/www/myapp/app/cache/dev' '--boring' '--images-dir' '/var/www/myapp/app/../web/uploads/img' '--config' '/var/www/myapp/app/cache/dev/assetic_compassu3IAzJ' '--sass-dir' '' '--css-dir' '' '/var/www/formation-hero/app/cache/dev/assetic_compassPbwM3H.scss'
Error Output:
sh: 1: /root/.rbenv/shims/ruby: Permission denied
I'm using Apache on Ubuntu 14.04
# which ruby
/root/.rbenv/shims/ruby
# which compass
/usr/local/bin/compass
# which rbenv
/root/.rbenv/bin/rbenv
# rbenv -v
rbenv 1.0.0-14-gc388331
Symfony 2.7 is installed under /var/www/myapp/
What should I do to either give right to Apache to use the /root repository or, maybe better, how do I install rbenv for my Symfony2 project?
Everything is working fine on my localhost with OS X.
I do not have experience with the said components but assuming that the user who is executing the file is www-data it might be an issue with the permissions of the /root/.rbend/shims/ruby file.
Run the command sudo chmod o+x /root/.rbenv/shims/ruby wich will give execute permissions to the owner of the file, presumably www-data since you ran the chown command.
If it still doesn't work run the command ls -l /root/.rbenv/shims/ruby, the 4th character of the first column should be x, indicating the owner has execution permissions.
For more info on linux file permissions check "Understanding and Using File Permissions".
I'm learning to use Bootstrap and spent the last few hours wrestling with Terminal as I tried to install the software that accompanies it - Ruby, Rails, SASS and two or three more. It was a failure, though I did get most of the programs installed.
Now it appears that Rails has hijacked my Terminal. I tried installing another toy I wanted to try out, Symfony. When I type in the install command
$ curl -LsS http://symfony.com/installer > symfony.phar
$ sudo mv symfony.phar /usr/local/bin/symfony
$ chmod a+x /usr/local/bin/symfony
I get this message:
-bash: $: command not found
Davids-MacBook-Pro:Rail myname$
I get the same message if I type in $ php --version
Anyway, the word "Rail" leads me to suspect that Terminal is in Rails mode. Can anyone tell me how to turn it off? I wasn't allowed to ask about it on the Apple forum; they seem to have a problem with questions related to this topic. ;)
Thanks.
P.S. I'm using OSX Yosemite.
The commands to install symfony, make sure you enter them one at a time and don't include the $ which is causing the error.
You can configure what appears currently as
Davids-MacBook-Pro:Rail myname$
by going typing cd to go to your home directory and than nano .bash_profile
By the way Bootstrap is just a css, html, and a bit of javascript framework/library that you can use with a bunch of different languages doesn't have to be Ruby on Rails. Also ruby is installed on yosemite by default but you might need to update it and Rails automatically includes SASS (Both Rails and SASS are gems).
The :Rail in Davids-MacBook-Pro:Rail myname$ indicates that you're currently in a folder named Rail. There is no "Rails mode," and Rails will not "hijack" your terminal.
Type the pwd command to reveal which folder you're in (which I'm guessing is a folder named Rail).
If you cd into another folder, your command prompt will update to reflect that:
Davids-MacBook-Pro:Rail myname$ cd ~/Desktop
Davids-MacBook-Pro:Desktop myname$
I have installed rvm for multiuser,
when I am doing bundle install, it is giving me error,
linux:/var/rails_apps$ bundle install
ERROR: RVM Ruby not used, run `rvm use ruby` first.
linux:/var/rails_apps$ rvm use ruby
mkdir: cannot create directory `/usr/local/rvm/log/ruby-2.0.0-p247': Permission denied
I already did,
sudo chmod 777 /var/rails_apps/
Please suggest..
You have a multiuser installation of rvm - this is not recommended because of the troubles you can get with it (like yours).
Since you are already there this should fix it:
rvmsudo rvm get stable --auto-dotfiles
rvm fix-permissions system
Also make sure you are in rvm group - if not add yourself:
rvm group add rvm $USER
and log in to a new shell (log out and log back in).
In most of the cases rvm fix-permissions will resolve the problem for single user access but it fails in some cases while making other rvm commands thereafter. So do it with rvmsudo after the fix-permissions command consecutively as
rvm fix-permissions
rvmsudo rvm use ruby
For those who may have issues after running the commands shared on every thread out there, try opening ubuntu or the Linux environment you are working with as an administrator.
1 - Search for your app (in my case Ubuntu) using the search bar on the bottom-left of your computer's screen.
2 - if you don't see the option "open as administrator" on the right side, then right-click over the app's icon and you should see it then.
3 - Allow the app to make changes on your computer when prompted and then try the installation commands again.
4 - If that didn't work then try the commands shared in this or other posts, but always as administrator.
I recently upgraded to Ruby 2 and Rails 4
$ ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]
$ rails -v
Rails 4.0.0
Now, when I create a new rails app, when the bundle install part happens, I get asked for my system password, which never used to happen before. It also takes forever. Reference screenshot: http://i.imgur.com/6kh4g63.png
Secondly, whenever a gem shows up in my Gemfile which I don't already have, it requires installation. In this case, I flat out get a permission denied error. Reference screenshot: http://i.imgur.com/rcIq5Vq.png
Also, when I want to run "rake db:migrate", I have to run it with sudo now, whereas previously this wasn't the case. If I do sudo bundle install, then even my Gem installation problem gets fixed.
However, this is not how my workflow used to be, and I want to figure out why this is suddenly the case. Even my rails server which I previously could start by simply typing "rails s" now requires me to type "sudo rails s".
Does anyone know what is causing this and how I can fix it?
Thank you.
Okay, so I think I've solved it. Not sure if this is good practice or not, but it worked, so I thought I'd answer it:
First, I found out where my rails is located, by typing: "which rails"
It gave me: /usr/local/rvm/gems/ruby-2.0.0-p247/bin/rails
So I went to that folder: cd /usr/local/rvm/gems/ruby-2.0.0-p247/bin
I saw that everything was owned by root. So I changed that to my username:
sudo chown -R Myname *
I did the same for ruby: "which ruby"
cd /usr/local/rvm/rubies/ruby-2.0.0-p247/bin
sudo chown -R Myname *
I thought this would work, but when a new gem would install, the folder it would try to copy in would not have write permissions for my username. This folder was: /usr/local/rvm/gems/ruby-2.0.0-p247/build_info/
So I did: cd /usr/local/rvm/gems/ruby-2.0.0-p247
And then owned the folder: sudo chown -R Myname build_info
And voila, everything is working now.
Please correct me if this is bad practice or unsafe.
Thank you.
After the reboot which was required to update all the packages,
ruby -v
doesn't work. It says rails is not installed either, but I guess it should be the similar issue. when I do:
sudo apt-get install ruby
It says the newest version is already installed.
When I do:
dpkg -L ruby
I get the following output:
/.
/usr
/usr/bin
/usr/share
/usr/share/doc
[and other stuff..]
But I realized $PATH already includes /usr/bin:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin
:/sbin:/bin:/usr/games:/home/ubuntu/.rvm/bin
May I know why I'm still getting the following error message?:
The program 'ruby' is currently not installed. You can install it by typing:
sudo apt-get install ruby
My .bashrc already has this too:
PATH=$PATH:$HOME/.rvm/bin
dpkg will be checking in a database that it maintains, whereas trying to execute ruby uses the PATH. If I recall correctly, Ubuntu has a bash handler configured to execute when any command is unresolvable; it seems that it just displays that generic message rather than checking with dpkg first.
It is possible that ruby has disappeared from your filesystem (or at least the directory it previously resided in), or that your PATH was changed.
What do you get if you execute "which ruby" and "where ruby"?
Lastly, Ubuntu can complain that a program cannot be found when it is present. This occurs when running a 64-bit version of Ubuntu, without the necessary x86 libraries installed, and trying to execute a 32-bit binary. However, I recall the error message being more along the lines of "file not found".