ruby - heroku: command not found - ruby-on-rails-3

this question has been posted befour, but the answers haven't worked. I should proberley mention that i am completely new to ruby. i incountered the error while doing a tutorial here are the steps:
[first_app (master)]$ gem install heroku
I get
Successfully installed heroku-2.24.0
but when i try
[first_app (master)]$ heroku keys:add
I get
-bash: heroku: command not found
i then tried a bunch uninstalling the gem updating bundle reinstalling it but that hasn't helped
$ bundle exec heroku
/Users/vng/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1/gems/bundler-1.1.3/lib/bundler/rubygems_integration.rb:147:in `block in replace_gem': heroku is not part of the bundle. Add it to Gemfile. (Gem::LoadError)
from /Users/vng/.rbenv/versions/1.9.3-p125/bin/heroku:18:in'`
echo $PATH
/Users/vng/.rbenv/shims:/Users/vng/.rbenv/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
my gem environment
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.11
- RUBY VERSION: 1.9.3 (2012-02-16 patchlevel 125) [x86_64-darwin11.3.0]
- INSTALLATION DIRECTORY: /Users/vng/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1
- RUBY EXECUTABLE: /Users/vng/.rbenv/versions/1.9.3-p125/bin/ruby
- EXECUTABLE DIRECTORY: /Users/vng/.rbenv/versions/1.9.3-p125/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-11
- GEM PATHS:
- /Users/vng/.rbenv/versions/1.9.3-p125/lib/ruby/gems/1.9.1
- /Users/vng/.gem/ruby/1.9.1
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
help is greatly appreciated

When you install gems that have binaries (executables) you must run
rbenv rehash
to add the executables to your path.

Related

How do I resolve "Could not locate Gemfile" when trying to initialise a react native project?

When running the command npx react-native init myProject --version 0.63.0 it gives back the error:
✖ Installing Bundler
error Could not locate Gemfile
I am using react-native 0.63 as I am on Mac OS 10.13.6. Xcode 12 is required for react-native 0.64, which I can't get on this old OS (please don't suggest to upgrade it's not a feasible solution). I understand the error is caused by a Gemfile not existing in the project directory, but how can I resolve this?
I have followed the installation steps as per https://reactnative.dev/docs/0.63/environment-setup.
Here is the output when I run cd myProject && gem env
RubyGems Environment:
- RUBYGEMS VERSION: 3.1.6
- RUBY VERSION: 2.7.4 (2021-07-07 patchlevel 191) [x86_64-darwin17]
- INSTALLATION DIRECTORY: /Users/toast/.rvm/gems/ruby-2.7.4
- USER INSTALLATION DIRECTORY: /Users/toast/.gem/ruby/2.7.0
- RUBY EXECUTABLE: /Users/toast/.rvm/rubies/ruby-2.7.4/bin/ruby
- GIT EXECUTABLE: /usr/local/bin/git
- EXECUTABLE DIRECTORY: /Users/toast/.rvm/gems/ruby-2.7.4/bin
- SPEC CACHE DIRECTORY: /Users/toast/.gem/specs
- SYSTEM CONFIGURATION DIRECTORY: /Users/toast/.rvm/rubies/ruby-2.7.4/etc
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-17
- GEM PATHS:
- /Users/toast/.rvm/gems/ruby-2.7.4
- /Users/toast/.rvm/rubies/ruby-2.7.4/lib/ruby/gems/2.7.0
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
- SHELL PATH:
- /Users/toast/.rvm/gems/ruby-2.7.4/bin
- /Users/toast/.rvm/gems/ruby-2.7.4#global/bin
- /Users/toast/.rvm/rubies/ruby-2.7.4/bin
- Users/toast/bin/dafny
- /usr/local/share/dotnet/dotnet
- /Users/toast/.cargo/bin
- /Library/Frameworks/Python.framework/Versions/3.7/bin
- /Library/Frameworks/Python.framework/Versions/3.8/bin
- /Library/Frameworks/Python.framework/Versions/3.7/bin
- /opt/local/bin
- /opt/local/sbin
- /usr/local/bin
- /usr/bin
- /bin
- /usr/sbin
- /sbin
- /Users/toast/.rvm/bin
Proof of my installations
$ ruby --version
ruby 2.7.4p191 (2021-07-07 revision a21a3b7d23) [x86_64-darwin17]
$ rvm --version
rvm 1.29.12 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io]
$ gem --version
3.1.6
$ pod --version
1.10.1
Use below command for install/update cocoapods
sudo gem install cocoapods
then create app with npx react-native init myProject --version 0.66.4

`rbenv rehash` not generating shims (using rbenv-gemset plugin)

I'm using rbenv and rbenv-gemset to manage the gems for a middleman project.
Even though I've run the rbenv rehash command, the shim for middleman does not exist:
→ middleman git:(master) × rbenv which middleman
rbenv: middleman: command not found
You can see here that I do have the middleman gem installed though:
→ middleman git:(master) × gem list middleman
*** LOCAL GEMS ***
middleman (3.1.5)
middleman-core (3.1.5)
middleman-more (3.1.5)
middleman-sprockets (3.1.4)
And here it is in my rbenv-gemset directory:
→ middleman git:(master) × ls .gems/gems
middleman-3.1.5
middleman-core-3.1.5
middleman-more-3.1.5
middleman-sprockets-3.1.4
And here you can also see there is a middleman command in the rbenv-gemsets directory:
→ middleman git:(master) × ls .gems/bin/
bundle erubis kramdown padrino rails rake2thor ri sass-convert sprockets tilt
compass haml middleman rackup rake rdoc sass scss thor tt
Yet running rbenv rehash does not generate the middleman shim (among others) :
→ middleman git:(master) × ls ~/.rbenv/shims
bundle dnsimple.rb gem rackup rdoc sass sdoc testrb tt update_rubygems
compass erb httparty rails ri sass-convert sdoc-merge thor unicorn
dnsimple erubis irb rake ruby scss sprockets tilt unicorn_rails
Here is my gem environment:
→ middleman git:(master) × gem env
RubyGems Environment:
- RUBYGEMS VERSION: 2.0.7
- RUBY VERSION: 1.9.3 (2013-06-27 patchlevel 448) [x86_64-darwin12.4.0]
- INSTALLATION DIRECTORY: /Users/asgeo1/Projects/myproj/middleman/.gems
- RUBY EXECUTABLE: /Users/asgeo1/.rbenv/versions/1.9.3-p448/bin/ruby
- EXECUTABLE DIRECTORY: /Users/asgeo1/Projects/myproj/middleman/.gems/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-darwin-12
- GEM PATHS:
- /Users/asgeo1/Projects/myproj/middleman/.gems
- /Users/asgeo1/.rbenv/versions/1.9.3-p448/gemsets/global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- https://rubygems.org/
What could be going wrong? Is this an issue with rbenv or rbenv-gemset?
funnily enough, somebody reported the exact same problem just a few days ago - and with middleman too. The problem has now been fixed (see https://github.com/jf/rbenv-gemset/issues/48). The problem in this case was rbenv-gemset. Sorry about that!
You can upgrade to the latest version of rbenv-gemset to get the fix (are you using git? or homebrew?)
EDIT #asgeo1, you might want to "accept" that answer, so that others who come by will be helped as well. Thanks.

How to configure rvm with netbeans

I have installed ruby 1.9.2-p1890 in my rvm and the gem directory is
/Users/abhay/.rvm/gems/ruby-1.9.2-p180
My netbeans detected the rvm and the ruby installed but when i right click the project properies->manage
gem home is - /Users/abhay/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1
gem path is - /Users/abhay/.rvm/rubies/ruby-1.9.2-p180/lib/ruby/gems/1.9.1
gem tool is - /Users/abhay/.rvm/rubies/ruby-1.9.2-p180/bin/gem (1.8.24)
interpreter - /Users/abhay/.rvm/rubies/ruby-1.9.2-p180/bin/ruby
and when I run my project, I get this error
/Users/abhay/.rvm/rubies/ruby-1.9.2-p180/bin/ruby: No such file or directory -- script/server (LoadError)

Gem::LoadError: Could not find rubygems-bundler (>= 0) amongst []

I'm running rvm with ruby 1.9.3. I've ran bundle install and it worked fine. But when I run bundle install --deployment I get this:
volunteer-app ➜ bundle install --deployment
Fetching gem metadata from http://rubygems.org/.......
Installing rake (0.9.2.2)
Gem::LoadError: Could not find rubygems-bundler (>= 0) amongst []
An error occured while installing rake (0.9.2.2), and Bundler cannot continue.
Make sure that `gem install rake -v '0.9.2.2'` succeeds before bundling.
After this is ran I look in the vendor/bundle/ruby directory and it shows 1.9.1. So it looks like bundle install --deployment isn't recognizing my gems in from rvm's default ruby version 1.9.3.
Any thoughts on what I could be missing.
Edit
Here's my gem env:
RubyGems Environment:
- RUBYGEMS VERSION: 1.8.24
- RUBY VERSION: 1.9.3 (2012-04-20 patchlevel 194) [x86_64-linux]
- INSTALLATION DIRECTORY: /home/sosl/.rvm/gems/ruby-1.9.3-p194#teer
- RUBY EXECUTABLE: /home/sosl/.rvm/rubies/ruby-1.9.3-p194/bin/ruby
- EXECUTABLE DIRECTORY: /home/sosl/.rvm/gems/ruby-1.9.3-p194#teer/bin
- RUBYGEMS PLATFORMS:
- ruby
- x86_64-linux
- GEM PATHS:
- /home/sosl/.rvm/gems/ruby-1.9.3-p194#teer
- /home/sosl/.rvm/gems/ruby-1.9.3-p194#global
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
It's a bug in both rubygems-bundler and bundler, I have already fixed it for rubygems-bundler and a fix for bundler is waiting for merge.
Fastest way to fix is to update rubygems-bundler:
gem update rubygems-bundler
For reference here is pull request for bundler:
https://github.com/carlhuda/bundler/pull/1925
I really feel for you as I just went though something simular last night. While I am certainly not an expert (I am just a student of RoR as you are) can I make some suggestions?
After you use RVM to change into your RUBY version, run a "local" gem list to see what gems are installed locally. Do you have the gem installed in your local gems?
Sometimes gem files get "Jumbled" and stop working altogether. Have you tried to uninstall and then reinstall the gems? The command is simple. In your console type "gem uninstall (the name and version number of the gem you wish to uninstall). It may reply that the gem you wish to uninstall has dependencies on other gems you have installed. Don't worry once you reinstall those gems the dependencies will be satisfied.
I don't know if Bundler is installed automatically or not. Is it listed in your "Local" gems or in your gemfile.lock?
Best of luck in correcting this.

rails 3: gems installed successfully, but cannot use them in my app

I did a clean install of rails 3.0.6. My app is running fine, except that I cannot use all the gems that didn't come with rails 3. All of them are in gem list. I also have them in Gemfile and have ran bundle install and bundle update.
For example, with matthuhiggins-foreigner:
upon rake db:migrate, it complains
that add_foreign_key is not defined.
I have the same problem with less:
no .css generated from .less)
geokit-rails3:
Unknown key(s): origin, within
gem which geokit-rails3 returns:
/Library/Ruby/Gems/1.8/gems/geokit-rails3-0.1.3/lib/geokit-rails3.rb
gem environment returns:
RubyGems Environment:
- RUBYGEMS VERSION: 1.5.0
- RUBY VERSION: 1.8.7 (2009-06-12 patchlevel 174) [universal-darwin10.0]
- INSTALLATION DIRECTORY: /Library/Ruby/Gems/1.8
- RUBY EXECUTABLE: /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby
- EXECUTABLE DIRECTORY: /usr/bin
- RUBYGEMS PLATFORMS:
- ruby
- universal-darwin-10
- GEM PATHS:
- /Library/Ruby/Gems/1.8
- /Users/administrator/.gem/ruby/1.8
- /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/gems/1.8
- GEM CONFIGURATION:
- :update_sources => true
- :verbose => true
- :benchmark => false
- :backtrace => false
- :bulk_threshold => 1000
- REMOTE SOURCES:
- http://rubygems.org/
I have looked into this problem for a long time. Please help!
Thanks!
Rails 3 does not load any gems that are not listed in your Gemfile, even if they are installed on your system. You need to explicitly list them there first.
The typical workflow in R3 is not to install your gems and then use them, but to write entries in the Gemfile and then install them by installing bundler with "gem install bundle" and getting all the remaining gems with "bundle install". Bundle install will install any required gems you do not already have, but will use the ones you do have.
(Bundle update, suggested by another user, will bump all your gems to the most recent available version that matches your requirements as laid out in the Gemfile, even if the ones already installed satisfy the requirements). i.e. if you need foo_gem >= 1.0 and you have foo_gem 1.0.1 installed, "bundle install" won't change it but "bundle update" will install foo_gem 1.0.3 if it's available.
If you are working on multiple applications that have conflicting (or potentially conflicting) gems, then I recommend learning about RVM and creating a gemset for each project. This is especially valuable if you are still working on any Rails 2.x projects alongside your R3 projects.
Try this:
Update gem by running gem update --system
Make sure your gemfile lists the gems
Run bundle update to update all your gems in the gemfile
Hopefully that should do the trick.
I came back to this problem after a few days and I fixed all the issues!
matthuggins-foreigner gem is called foreigner, so I added this to Gemfile:
gem 'foreigner'
With geokit, I simply followed the instructions here:
https://github.com/jlecour/geokit-rails3
With less, I installed the less gem and the more plugin, then restarted the server:
https://github.com/cloudhead/more