Coda Terminal can't find rails - ruby-on-rails

I've installed rails using rvm and everything works well in the out of the box terminal using zsh. I thought i'd simplify things a bit and bring out Coda's terminal but for some reason when I run
$ rails --version
I get errors saying there are missing dependencies or when using $ rails new new_app Coda terminal tells me that rails isn't installed. running $ gem list and $ gem environment give me the same output in both terminals.

you need to load rvm before using it
load rvm script with
source ~/.rvm/bin/rvm

Related

Using rvm bundle install doesn't install rails

I'm freshly using rvm for running a legacy project.
I installed rvm fine. Running which ruby gives the correct rvm version:
/Users/Mahmoud/.rvm/rubies/ruby-2.5.5/bin/ruby
Then running which bundle, also indicates that bundle is using the correct rvm version:
/Users/Mahmoud/.rvm/rubies/ruby-2.5.5/bin/ruby
Now to get my project running, I run bundle install. It's important to stress on the fact that in my Gemfile I have
gem 'rails', '5.0.7'
Running rails s after those steps, gives:
Rails is not currently installed on this system. To get the latest version, simply type:
Running which rails gives:
/usr/bin/rails
implying that the system version and not the rvm version is being used.
echo $PATH shows:
/Users/Mahmoud/.rvm/gems/ruby-2.5.5/bin:/Users/Mahmoud/.rvm/gems/ruby-2.5.5#global/bin:/Users/Mahmoud/.rvm/rubies/ruby-2.5.5/bin:/Users/Mahmoud/.rvm/bin:/Users/Mahmoud/.pyenv/versions/3.7.2/bin:/usr/local/bin:/Users/Mahmoud/.pyenv/bin:/usr/local/opt/openssl#3/bin:/usr/local/opt/openssl#3/bin:/usr/local/opt/libxml2/bin:/usr/local/opt/mysql#5.7/bin:/usr/local/opt/mysql#5.7/bin:/usr/local/opt/mysql#5.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/MacGPG2/bin:/Library/Apple/usr/bin:/Users/Mahmoud/.ebcli-virtual-env/executables:/usr/local/mysql/bin
My question is, why hasn't rails been installed when I used bundle install? And why is which rails refering to my system and not my rbenv path?
I'll bet your RVM isn't set up correctly and /usr/bin/ appears in your PATH before RVM's bin directory. Run echo $PATH to confirm.
If so, back up your dotfiles for safety and run rvm get head --auto and it should put your PATH right. Logout and log back in or source your dotfiles (source ~/.bash_profile or whatever) and try again.

Rails - Closed terminal and rebooted machine - now bash tells me rails isn't installed

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.

Rails command Error

Im about to start work on another web application, I change directories to
/rails_projects
and enter
rails new blank
I then get this error
Error: Command not recognized
Usage: rails COMMAND [ARGS]
The common rails commands available for engines are:
generate Generate new code (short-cut alias: "g")
destroy Undo code generated with "generate" (short-cut alias: "d")
All commands can be run with -h for more information.
If you want to run any commands that need to be run in context
of the application, like `rails server` or `rails console`,
you should do it from application's directory (typically test/dummy).
I have reinstalled rails, and still same error, any ideas?
UPDATE:
It actually give me the same error when I type just
rails -h
rails
in cmd
For anyone with a similar error that may land here, this fixed it for me:
rake rails:update:bin
This will generate "new" versions of the binaries. Just say Yes when it inquires you to replace them.
I ran into a similar issue when trying to upgrade a Rails Engine from 3.2 to 4.1.
The culprit was the presence of script/rails which contained:
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
ENGINE_ROOT = File.expand_path('../..', __FILE__)
ENGINE_PATH = File.expand_path('../../lib/my_project/engine', __FILE__)
require 'rails/all'
require 'rails/engine/commands'
The problem line is there at the end: require 'rails/engine/commands. That was not allowing the full Rails CLI to load which omitted the new command. Removing that file solved my problem.
I'm pretty sure this wasn't the cause of your specific problem, but the symptoms were the same as mine and this was the first link in Google for the error message. Just passing along my findings to help anyone else that runs into this same situation.
It looks like the rails command believes it's inside of a rails engine, which is why a different set of commands are available to you. Notice the 'commands available for engines' text. New is not a command available for engines. I'm not sure why rails thinks the directory you're in is an engine, but likely your directory structure is mixed up somehow.
If anyone runs into this error and needs a last resort plan.
I ended up uninstalling rails, rvm, and installing a newer version of ruby and new gemset.
rvm implode
gem uninstall rails -v=4.0.2
gem uninstall railities
install rvm :
curl -L https://get.rvm.io | bash -s
rvm get stable
for mac:
brew install libtool libxslt libksba openssl
brew install libyaml
install ruby:
rvm install 2.0.0 --with-openssl-dir=$HOME/.rvm/usr
if you have error
rvm install 2.0.0 --with-openssl-dir=$HOME/.rvm/opt/openssl
install new ruby gems from website. Unpackage it then go to folder and run
ruby setup.rb
gem update --system 2.1.9
install rails (you can choose your version)
gem install rails --version 4.0.2
gem install railties
I did this, and now system is working normal again.
Create another directory and run $ruby -v, check which version is available. Now run rails new app_name. Try once after closing the terminal and restarting.
This happen to me when a require error occurred in a gem (dependency) while loading.

Two versions of rails showing up when i run gem list rails

I just installed ruby and rails. When i run 'ruby -v' command it shows version of ruby that's currently installed. Similarly, I need to check the version of rails as well. Since rails was installed using RVM, the 'rails -v' command is not working. When i run the 'gem list rails' command, it shows two versions of rails. But when i try 'which rails' command, nothing happens. Please help find the version of rails installed.
Have you tried to run this into your console:
$ rails --version
Can't test from here but I'm pretty sure it was --version with rails.
If you want to know which version a specific app is running, you can simply open Gemfile and see. Should be one of the first lines.

Rake, bundle, rails command not found on rvm

I just installed rvm + rails 3+ on centos 6.0 at Rackspace cloud server. Everything works fine, but sometimes when i ssh to server i can't use rake, bundle or any other rails related commands it always shows me errors like:
bash: rake: command not found
when i try to run bundle install it shows me this error:
ERROR: Gem bundler is not installed, run `gem install bundler` first.
but i do have it installed for sure and it worked before.I can use rvm rake db:migrate - but it used to without rvm prefix...Please help i dont know why is that happening - maybe something wrong with bash profile...
have you used a ruby ?
rvm use 1.9.3
this will select properly environment and make all commands working properly.
to make this setting permanent for new sessions also use:
rvm use 1.9.3 --default

Resources