How do I properly setup Aptana RadRails if I've installed Rails through RVM?
I followed the install on http://railstutorial.org/ but my script paths don't work: e.g.:
'rails' path: /home/marius/.rvm/gems/ruby-1.8.7-p302#rails3gemset/bin/rails
Detected path: Not Detected
After installing ruby through rvm, I was able to get eclipse to use that install by:
In Eclipse, go to Window -> Preferences.
In the Ruby/Interpreters tab click "Search"
For me this found all of the ruby installs from rvm, and it added them to the interpreters list. I edited the "Name" field to include the version number for convenience.
try to run this in the command line. It will show you real path to the available rail script for current environment.
$ which rails
In Aptana Studio 3 (build: 3.0.8.201201201658) there is no Window -> preferences. If you have a .rvmrc in your project work directory, stating for instance:
rvm use ruby-1.9.3-p0#mygemset
... then Aptana should pick up the correct environment; in this case using ruby-1.9.3-p0 with gemset mygemset. Don't forget to run build install or build update (when you updated your Gemfile) from your project working directory path.
I must add that Aptana Studio 3 seems a bit buggy when it comes to picking up the correct environment, especially when trying to use ruby-debug-ide19.
Did you try with just /home/marius/.rvm/gems/ruby-1.8.7-p302/bin/rails ?
You have to run eclipse/aptana from a terminal session.
Without RVM :
Please type command whereis ruby in console.
you will get the path like /usr/bin/ruby or /usr/local/bin/ruby to check which is correct interpreter path /usr/bin/ruby -v if you get version. that is your interpreter.
With RVM :
Please type command: rvm info
binaries:
ruby: "/home/<USERNAME>/.rvm/rubies/ruby-2.0.0-p247/bin/ruby"
copy this path and paste wherever you need enter you interpreter path.
It worked for me. and I hope it will help others as well.
Cheers!
Related
I removed the previous version of ruby I installed, ruby 1.9.1 to be precise, on my Ubuntu, and installed version 2.2.3. When I try to run bundle install on my terminal, I get this error
bash: /usr/local/bin/bundle: /usr/bin/ruby1.9.1: bad interpreter: No such file or directory.
Can anyone advice on how to fix it?
How did you remove the old version of Ruby?
It looks like it left the binary executable for bundler, so I'm guessing you just straight up deleted the usr/bin/ruby folder? Ruby installations (and most installations) tend to create executable binaries in other folders that need to be deleted as well.
I would highly recommend that you use something like rvm or rbenv to manage multiple versions of ruby on your system. Those tools are designed to do that sort of thing and are basically industry standard at this point.
My personal recommendation is rvm, although either is really fine. If you choose to go with that, check out rvm.io for installation instructions.
It'll install rvm with the latest ruby version. In addition to that you are free to install any other version of ruby or patch that you prefer, and you can easily switch between the two using rvm use <ruby version>
Yesterday I installed ruby and rails using rvm in ubuntu 12.04 and it is working fine and also created a sample application.But today when i run
ruby -v
it is showing like
The program 'ruby' can be found in the following packages:
ruby1.8
ruby1.9.1
Try: apt-get install
You probably forgot the latest step when installing RVM. It is mentioned at the end of the install process but easily overlooked. It boils down to this:
Make sure you have the following lines at the bottom of ~/.bashrc:
PATH=$PATH:$HOME/.rvm/bin # Add RVM to PATH for scripting
source "$HOME/.rvm/scripts/rvm"
This will load RVM right after you open a new shell. Without it, RVM is not 'activated' and when you type ruby it will use the version installed through your OS package manager and not the version installed through RVM.
Run rvm list. If it shows rubies then everything is ok and go to step 2.(if any problems then try reinstall rvm)(if it shows empty rubies list, then install ruby using rvm again(rvm install 2.1.1)
Specify current rvm ruby by one of the following ways:
Specify ruby version manually by running rvm use 2.1.1 for ruby2.1.1. This way you have to call this command every time you open a terminal (see next ways if this doesn't suit you)
Set default ruby version. See here.
Use .rvmrc file in any directory(see here how) to make rvm change ruby version when you open this directory.
Probably that is your case.
In addition to zwipple's answer, if you can also load rvm for once using following command:
source ~/.rvm/scripts/rvm
ruby -v
=> #your ruby version
Running OSX Mavericks, ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0], rvm 1.25.23 (master), and rails-4.1.0 (allegedly)
I'm working through the railsapps.org book on learning rails and made it about 1/2 way through yesterday. When I stopped for the day, I closed out iTerm2 and shut off the Macbook Pro. Today, I powered up, opened iTerm, navigated to my working directory (~/rubyonrails/learn-ruby) and entered rails -v.
I see this:
`Rails is not currently installed on this system. To get the latest version, simply type:
$ sudo gem install rails
You can then rerun your "rails" command.`
So I run sudo gem install rails and it shows that it has installed rails-4.1.0. Now rails -v still gives me the same error message above.
I tried also running rvm use ruby-2.1.1#learn-rails first and I still get the error message.
So I'm a little stuck and I can't figure out what to do to get rails working. Also, how do I go about setting up the bash environment such that I don't have to go through this each time? It would be nice to nav to my working directory and just start work without having to do a bunch of re-installation and reconfiguration each time.
Regards,
Jeff
please type in your shell:
$ bash --login
and then repeat your commands.
rails -v
Also try to call it with the full path:
like:
/your/path/to/rails -v
I think that the shell just doesn't know where rvm/rails etc is located.
You can solve this by entering:
$ source ~/.rvm/scripts/rvm
When you switch to the ruby-2.1.1#learn-rails ruby/gemset combo, and do gem list, what do you see?
The way people usually use rvm is to have every project folder specify the ruby & gemset it uses (they don't all have to be different). This is done with files called .ruby-version and .ruby-gemset. These should contain, in your case, ruby-2.1.1 and learn-rails respectively.
Set these if you haven't already, then leave the folder and enter it again. Then do bundle install to install the gems for the project into the rvm/gemset combo.
Your problem is that you ran
sudo gem install rails
The error message telling you to do this comes from your system Ruby, which doesn't know that you want to use RVM.
RVM installs gems into your user-space directory. By using sudo, you're bypassing this and installing it into (effectively) the superuser space, i.e. globally.
If you instead just run
gem install rails
then you'll be using RVM's copy of the gem utility rather than the globally installed version.
This is a beginner-level question.
I'm using Ubuntu 12.04
I copied a project (created on Rails 4 using the rails new command) from Dropbox to my local environment, where I have previously install Rails 4 and up-to-date Ruby and RVM, went to project's directory, typed rails server and got
The program 'rails' is currently not installed. You can install it by typing:
sudo apt-get install rails
I ran gem install rails instead.
Will I have to run gem install rails on every project's directory? I thought the Rails install was a general and accessible on my whole environment.
The project was created using the same Ruby version, but on a MacOS X system.
The project is a static web brochure and has no database configuration.
Thank you in advance.
Make sure you're using the correct version of Ruby - the same version that you'd installed Rails into - with rvm list.
You likely have two of them (since you have such an issue) - the system Ruby and the RVM-installed Ruby. And likely RVM didn't engage and hook up the correct path to the rails executable, thus the error.
This should fix the issue:
rvm use whatever-ruby-you-had-installed-rails-into
Where whatever-ruby-you-had-installed-rails-into is a string like ruby-2.1.0-p0 taken from the rvm list output.
To make RVM retain Ruby version for the project.
echo whatever-ruby-you-had-installed-into >.ruby-version
in your project's path.
So after a few hours of testing, reproducing the problem, and reading (the other answers inclusive) I got the solution as follows:
Short answer: No. Rails needs to be installed only once.
Long answer: This problem occurred because of a default setting on Terminal that prevents the system from using RVM installations of ruby and rails. The solution is to integrate RVM with gnome-terminal as described in the RVM website.
With terminal window active, go to the menu at the top bar
Edit > Profile Preferences > Title and Command tab
Check the Run command as a login shell box
Restart Terminal and make sure your gemset and ruby version are set
rails server should now work as expected (you might be prompted to run bundle install before Rails can actually run fine, follow the promtp).
I am still learning to work with Ruby on Rails, so any inputs, clarifications, or additional information on the issue is more than welcome.
You don't have to install Rails on every project, but the gems that you need for that project.
With bundle install you install all the gems that you specify in Gemfile.
If you want to avoid reinstall the gems every time you change project, I suggest you to have a better look to RVM: it has got an opt called gemset (https://rvm.io/gemsets), if you use it you just need to switch your gemset:
rvm gemset use yourgemset
I hope it can help you.
I installed ruby and next rails as a gem with this command
gem install rails -include-dependencies
It installed successfully but even after restarting my command window i couldnt run commands like:
rails
or
rails s
My question is what do i have to add to my path so that rails is recognized in my command windwo?
----Update----
I ran gem list but rails isnt listed,
so i will reune the gem install rails command
If you are using rvm you need to use the gemset of RVM in which you have installed your rails gem.
cmd for the same is
rvm gemset list
will list the gemset persent in your version manager, later select the gemset with following command:
rvm gemset use [gemset_name]
hope am redirecting you in the right direction.
Try creating a project with:
rails new whatever
Go into the project:
cd whatever
Install dependencies:
bundle install
Start server:
rails s
If you use a unix based OS, you may need to get the path of the rails executable into your $PATH e.g. by e.g. exec $SHELL -l.
Apologies if you know about this already, but why don't you use a pre-packaged installer like RailsInstaller?
Are you using rbenv?
If so, try running this in your terminal:
rbenv rehash
Since you are using windows, you might not have added Ruby's bin directory in path :
To add path in windows :
Right click My Computer >> properties >> Adavced System Settings
Then edit the path variable in User Variable and just add the path of your installed Ruby's bin directory.
Open a new command prompt to get the path changes.