Cannot find Ruby or Rails in my computer after installing Heroku - ruby-on-rails

I just started to learn Rails from railstutorial.org. After installing Rails I cerated an app, set up git, installed Heroku gem, and uploaded SSH key to heroku.
After that, I turned off my computer and a few hours later I came back to continue with the next steps. First I ran heroku create --stack cedar.
Then,
git push heroku master I get the following error message:
[~ (master)]$ git push heroku master
fatal: 'heroku' does not appear to be a git repository
fatal: The remote end hung up unexpectedly
Same thing is happening for commands like rails heroku gem etc.
Also, I cannot find neither Ruby or Rails in my system. When I ran ruby -v I get
The program 'ruby' can be found in the following packages:
* ruby1.8
* ruby1.9.1
Try: sudo apt-get install <selected package>
Is this happening because I am running Ruby 1.9.3p125? Please help.

just type
rvm gemset list
rvm use 1.9.3#(you_gemset) --default
EDIT: i've looked this tutorial, and there he's created gemset: rails3tutorial2ndEd
then just type: rvm use 1.9.3#rails3tutorial2ndEd --default

You probably haven't set ruby 1.9.3 as your default ruby with rvm. You can do this by typing in the command line:
rvm use 1.9.3 --default
This should solve your problem.

Related

Rails cannot load such file -- stringio (LoadError)

My Rails app was working fine and then I decided to try to update it from 4.0 to 4.2 so I could put it on Heroku. The guide I was following said to update RubyGems so I ran this command:
$ gem update --system
Got this warning:
Warning! `PATH` is not properly set up, '/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin'
is not at first place, usually this is caused by shell initialization
files - check them for 'PATH=...' entries, it might also help to re-add
RVM to your dotfiles: 'rvm get stable --auto-dotfiles', to fix temporarily
in this shell session run: 'rvm use ruby-2.0.0-p353'
I ignored the warning and went to the next step in the guide.
I tried to create a gemset:
$ rvm use 2.0.0p353#rails4.0.2_myapp --create
Then I decided to not update because I was scared of breaking my app. So I just tried to push the app to Heroku without updating.
I ran
$ heroku login
$ heroku create
$ git push heroku master
It failed to push to Heroku because the slug size was too big. I went to fix it and then I started getting this error:
/Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:16:in `require': cannot load such file -- stringio (LoadError)
from /Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems/specification.rb:16:in `<top (required)>'
from /Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems.rb:1228:in `require'
from /Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems.rb:1228:in `<module:Gem>'
from /Users/devon/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/site_ruby/2.0.0/rubygems.rb:115:in `<top (required)>'
from <internal:gem_prelude>:1:in `require'
from <internal:gem_prelude>:1:in `<compiled>'
TLDR: App was working. Then I ran these commands:
$ gem update --system
$ rvm use 2.0.0p353#rails4.0.2_myapp --create
$ heroku login
$ heroku create
$ git push heroku master
Now I receive that LoadError error and can't run my app. How can I fix this? I'm assuming something broke when I ran
$ gem update --system
I read this question: no such file to load -- rubygems (LoadError), and someone says to check if you have two ruby versions installed so I ran:
$ which -a ruby
/Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
/usr/bin/ruby
but I don't know what to do after or if it even matters since I only ran those above commands after my app was working fine.
Here are my versions if it matters:
$ ruby -v
ruby 2.0.0p353 (2013-11-22 revision 43784) [x86_64-darwin12.5.0]
I can't run rails -v because I get the LoadError. But before the error I got this:
$ rails -v
Rails 4.0.2
Before error (I think this updated to a newer version after I ran the update command):
$ gem -v
2.4.8
EDIT
After trying to switch to old version of rubygems:
$ rvm rubygems 2.4.8
I got:
Warning! PATH is not properly set up, '/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin'
is not at first place, usually this is caused by shell initialization
files - check them for 'PATH=...' entries, it might also help to
re-add RVM to your dotfiles: 'rvm get stable --auto-dotfiles', to fix
temporarily in this shell session run: 'rvm use ruby-2.0.0-p353'.
ruby-2.0.0-p353 - #downloading rubygems-2.4.8
ruby-2.0.0-p353 - #extracting rubygems-2.4.8.....
ruby-2.0.0-p353 - #removing old rubygems..........
ruby-2.0.0-p353 - #installing rubygems-2.4.8.
Error running 'env GEM_HOME=/Users/devon/.rvm/gems/ruby-2.0.0-p353#global GEM_PATH= /Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -d /Users/devon/.rvm/src/rubygems-2.4.8/setup.rb --no-document',
showing last 15 lines of /Users/devon/.rvm/log/1452506634_ruby-2.0.0-p353/rubygems.install.log
[2016-01-11 05:03:54] /Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin/ruby
current path: /Users/devon/.rvm/src/rubygems-2.4.8
GEM_HOME=/Users/devon/.rvm/gems/ruby-2.0.0-p353
PATH=/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin:/Users/devon/.rvm/gems/ruby-2.0.0-p353#global/bin:/Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin:/Users/devon/.rvm/bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/devon/my_stuff/android/adt-bundle-mac-x86_64-20130729/sdk/platform-tools:/Users/devon/my_stuff/android/adt-bundle-mac-x86_64-20130729/sdk/tools
GEM_PATH=/Users/devon/.rvm/gems/ruby-2.0.0-p353:/Users/devon/.rvm/gems/ruby-2.0.0-p353#global
command(7): env GEM_HOME=/Users/devon/.rvm/gems/ruby-2.0.0-p353#global GEM_PATH= /Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin/ruby -d /Users/devon/.rvm/src/rubygems-2.4.8/setup.rb --no-document
And then the stringio error occurs at the end here
EDIT 2:
$ echo $PATH
/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/Users/devon/.rvm/gems/ruby-2.0.0-p353/bin:/Users/devon/.rvm/gems/ruby-2.0.0-p353#global/bin:/Users/devon/.rvm/rubies/ruby-2.0.0-p353/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/Users/devon/.rvm/bin:/Users/devon/my_stuff/android/adt-bundle-mac-x86_64-20130729/sdk/platform-tools:/Users/devon/my_stuff/android/adt-bundle-mac-x86_64-20130729/sdk/tools
My best guess of what's happening:
The PATH warning that you received is because you updated the local rvm 'gem' command using the system ruby (in /usr/bin);
When you created the gemset, rvm fixed the path, but after this RubyGems from your system ruby is being run using your rvm ruby, and I guess the two versions do not match.
The easiest solution would be to completely remove and reinstall rvm:
$ rm -rf ~/.rvm
Reinstall rvm
Re-run bundle install
To confirm this is indeed the problem before deleting rvm, you can temporarily switch /usr/bin (put this first) and /Users/devon/.rvm/gems/ruby-2.0.0-p353/bin (and this after) in your PATH. At this point, gem -v should still give you 2.4.8, and /Users/devon/.rvm/gems/ruby-2.0.0-p353/bin/gem -v should work fine and give you the newer version of RubyGems.
Alternative solution
Something else (simpler) you could try is to force rvm to reinstall the older version of RubyGems, and then update it again (if required):
rvm rubygems 2.4.8
Have a look here for more details on managing RubyGems with rvm.

The `heroku' command exists in these Ruby versions:

I'm having major issues with the heroku toolbelt. I'm using the cedar 14 stack and when I am trying to use a ruby version that isn't ruby 2.0.0-dev I get this error.
rbenv: heroku: command not found
The `heroku' command exists in these Ruby versions:
2.0.0-dev
I need heroku to be working with ruby 1.9.3 and I don't think cedar 14 supports that version of ruby. Can someone explain first, why I am only allowed to use heroku with ruby 2.0.0-dev and also how I can install a older stack that supports ruby 1.9.3?
The problem is that there are two heroku executables on your system: one in system paths such as /usr/local/bin/heroku (provided by Toolbelt), and one in rbenv's shims because Ruby 2.0.0-dev had "heroku" gem installed.
Because rbenv's shims directory usually have higher precedence, it will block invocation from ever executing the heroku executable provided by Toolbelt.
The solution is to uninstall any instance of "heroku" gem and relying solely on Toolbelt for all heroku usage on the command line:
for v in `rbenv whence heroku`; do RBENV_VERSION=$v gem uni heroku -ax; done
rbenv rehash
which heroku
You can use 1.9.3 on the cedar stack according to this. The heroku toolbelt is installed as a executable not a ruby gem. How are you trying to execute the command? You should be able to use it from the terminal such as heroku run rake db:migrate etc.

Ruby error after installing heroku toolbelt

I am working with Heroku on a win 7 - 32 bit system where I don't have admin privileges.
I have downloaded and installed the heroku toolbelt following http://community.webfaction.com/questions/11803/heroku-toolbelt with
cd ~
curl http://assets.heroku.com/heroku-client/heroku-client.tgz | tar zx
export PATH=$HOME/heroku-client/bin/:$PATH
following Leo's advice ,I've added ruby to the windows path to fix this
Now when I run:
$ heroku run bash --app MYAPP
I get:
f:/heroku-client/lib/heroku/updater.rb:164:in `spawn': Exec format error - "m:/heroku-client/bin/heroku" update (Errno::ENOEXEC)
from f:/heroku-client/lib/heroku/updater.rb:164:in `background_update!'
from f:/heroku-client/lib/heroku/updater.rb:144:in `inject_libpath'
from f:/heroku-client/bin/heroku:19:in `<main>'
I have added to the windows env variable path:
F:/heroku-client/bin/;f:/heroku-client/lib/heroku/
How can I fix this?
I had the same issues initially with ROR on Windows. (Everyone suggested me to move to LINUX/UNIX)
Still I managed to install it on Windows. Rather than installing the Heroku Toolbet (which breaks ruby and rails which is already installed) install the heroku gem along with foreman gem.
gem install heroku
gem install foreman
Then u can use it easily.
Install the Windows Heroku Toolbelt. It's self-contained and should work out of the box for you.

Ruby on Rails: heroku database push

When I try and run heroku db:push I get this error.
-bash: /usr/local/bin/heroku: /usr/bin/ruby1.8: bad interpreter: No such file or directory
Any ideas?
Heroku can't find Ruby. This is common if you're using RVM or something to manage your Ruby installations. How did you install Heroku, and how did you install Ruby?

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