Ubuntu can't find rails as a user - ruby-on-rails

i am using ubuntu 12.04. I've installed rails with rvm. i added required lines to .bashrc and .bash_profile. however when i want to run rails terminal says:
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
i could run rails in my few attemps, but i used a different approach:
open a new terminal
logged as root sudo su
re-login my user account, login user
and it worked few times.

Had same problem, on my command line I fixed it by doing this
/bin/bash --login
hope it helps.

make sure:
rvm use ruby
works, follow all instructions displayed to you.

Related

Ubuntu rvm setup issue

I followed this tutorial below:
https://www.digitalocean.com/community/articles/how-to-install-ruby-on-rails-on-ubuntu-12-04-lts-precise-pangolin-with-rvm
This worked perfectly for me; however, I have one small problem?
Each time I open a new terminal I have to run this command in order for rails to work:
source ~/.rvm/scripts/rvm
What is the problem and why is rvm not recognized
This is what I see after I open a new terminal and verify rails:
robert#rob:~$ rails -v
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
Thanks
I highly recommend you to use the official website to install RVM: https://rvm.io/rvm/install
Your problem is that RVM is not loaded when you open a new terminal, this is why you have to manually add the source at each instance of the Terminal.
To solve this, run this command line: (if using login-shell)
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bash_profile
Or this (if using non-login shell):
echo "source $HOME/.rvm/scripts/rvm" >> ~/.bashrc
This will add the path to RVM to load at each Terminal instanciation (close & re-open a terminal after you did this).
Take a look at #mpapis comments

Rvm ruby Permission denied

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.

ruby in linux: permanently "source .rvm/scripts/rvm"?

I'm new to Ruby on Rails and have just set it up in Ubuntu Linux following instructions I found here. Specifically,
As s.m. said, I uninstalled everything, then I opened another terminal session as a normal user and run:
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
then i run source /home/my-desktop-username/.rvm/scripts/rvm as a normal user NOT ROOT
then i run rvm requirements as a normal user. Then I copy the requirements and close the session, open a root session and install the requirements using sudo
Then I close the session and open a normal user session and run rvm install ruby-1.9.3-p125 if you run this command as root, it will say that rvm is not installed and will suggest that you install it using sudo apt-get install rvm Don't do that!
So basically I had two problems, the tutorials that i followed didn't say that i should run
source /home/my-desktop-username/.rvm/scripts/rvm and didn't say that I should not run rvm as root, s.m told me that. Thanks to everyone, especially to s.m
That works well, but I will have to remember to
source .rvm/scripts/rvm
every time I open a terminal to work with Ruby on Rails.
Is there a way to permanently tell Ubuntu to look in .rvm for all the Ruby stuff?
You need to add your
source .rvm/scripts/rvm
into your $HOME/.bashrc file; read the advanced bash scripting guide for more.

Terminator could not find rails

I am using ubuntu 12.04 LTS.I have successfully installed ruby via rvm and rails.I can also see which version of rails and ruby in terminal by typing rails -v,ruby -v successively.On the other hand,I have installed terminator on my ubuntu and I have faced an error message while I was typing rails -v:
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
When I have typed ruby -v,no error message,it prints the version,no problem.
Please be noted that I have already installed ruby and rails successfully and it works correctly with terminal.
Here are some pictures of the situation:
http://imageshack.us/f/819/screenshotfrom201206281.png/
http://imageshack.us/photo/my-images/407/screenshotfrom201206281.png/
I had the same problem while using rvm.
To resolve it you should add:
source ~/.rvm/scripts/rvm
to your ~/.bashrc
I had a very similar problem. Many of the commands of my rails environment were not working on Terminator and the following solved it for me.
Right click on the Terminator window. Preferences > Profiles > Command and check "Run command as login shell"
Please refer to the following post as to why this works https://askubuntu.com/questions/121073/why-bash-profile-is-not-getting-sourced-when-opening-a-terminal
Here is some more insight on shell login from RVM https://rvm.io/support/faq#shell_login
I also enconter this problem like you , rails can run on terminal but not termilator, i can't resolve it. So I use tmux instead of termilator which also can splits windows and even more stronger.

problem doing bundle install on ubuntu

my situation is as follows:
I installed rvm as a root user on Ubuntu 10.04. As a root user I then installed ruby 1.9.2 and rails 3.0.1 using rvm at location '/rvm/gems/ruby1.9.2-p0/'. Then I logged in as myself on ubuntu and tried creating a rails application in /home/myself/www/myapp. When I do 'bundle install' I get the following error:
'Permission Denied' - home/myself/www/myapp/Gemfile.lock (Errno: EAccess) from /usr/local/rvm/gems/ruby1.9.2-p0/gems/bundler-1.0.7/lib/bundler/definition.rb
I am also not able to do sudo bundle install.
Moreover, when I log back in as root and try to do bundle install from there...I get error:
bash: bundle: command not found.
I am very lost now. How can I get this to work???
May you should check the permissions of your rails app folder, review the owner and group because I had the same problem and I has solved with:
chown -R USER railsapp_folder
Good luck!
When you logged in as root, did you activate rvm using
rvm use 1.9.2
EDIT:
How about (logged in as root)
rvm use 1.9.2
cd /home/myself/www/myapp
bundle install
rvmsudo runs as sudo in the current environment and from the path it was called from.
You need to make sure you've added:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
into your ~/.bashrc as per the instructions here (see "Post Install").
type rvm | head -1 should return rvm is a function if you've done it correctly.
I highly recommend starting over and installing RVM under your own account. This tutorial is perfect.

Resources