Heroku and adding SSH keys (trouble installing heroku gem - ruby

I am new to programming and trying to understand this error. The error is really strange because I have already installed the heroku gem (using sudo and not using sudo). I am using OS X.
skline-mac:~ skline$ sudo heroku keys:add
/Users/skline/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems.rb:861:in `report_activate_error': Could not find RubyGem heroku (>= 0) (Gem::LoadError)
from /Users/skline/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems.rb:255:in `activate'
from /Users/skline/.rvm/rubies/ruby-1.9.2-p136/lib/ruby/site_ruby/1.9.1/rubygems.rb:1204:in `gem'
from /Users/skline/.rvm/gems/ruby-1.9.2-p136#rails3tutorial/bin/heroku:18:in `<main>'

You're using rvm, so there's no need for sudo, either for gem install heroku or using the heroku gem. This should work without any use of sudo:
gem install heroku
heroku keys:add
If this does not work, try resetting the ownership on your .rvm directory to your own user account (because you used sudo at some point in the past):
sudo chown -R $USER:staff ~/.rvm

Related

run created gem as sudo

I am working on a gem and am trying to write to the /etc/hosts file however permission is denied as a normal user. Trying to do it via sudo appname patch_hostfile results in the following
.rvm/rubies/ruby-2.6.2/lib/ruby/site_ruby/2.6.0/rubygems.rb:284:in `find_spec_for_exe': can't find gem appname (>= 0.a) with executable vcdm (Gem::GemNotFoundException)
I think it is doing this because rake install only installs for the current user but sudo should have access to everything so I'm not sure if that is the problem.

Upgraded Heroku from gem to toolbelt, but still old version

Heroku recommends switching from the old gem to the new "Heroku Toolbelt":
https://blog.heroku.com/archives/2012/10/15/upgrading-to-the-heroku-toolbelt
I ran these commands successfully:
$ sudo gem uninstall heroku
$ sudo gem uninstall heroku --all
$ wget -O- https://toolbelt.heroku.com/install-ubuntu.sh | sh
Then I restarted my terminal, and... I still have the old version:
$ heroku version
heroku-gem/2.33.5 (x86_64-linux) ruby/1.9.3
$ heroku fork
! `fork` is not a heroku command.
$ which heroku
/home/me/.rvm/gems/ruby-1.9.3-p362/bin/heroku
What did I forget?
Similar questions:
How do I replace the Heroku gem with Heroku Toolbelt? but none of the answers work
Heroku toolbelt fails update and rails/heroku migrating from gem to toolbelt but I have no ~/.heroku/client folder
It looks like you still have the gem installed in one of your rvm installations.
Try removing the gem without sudo:
gem uninstall heroku
The value of which heroku should not be in the ~/.rvm folder, but /usr/local.

Building native extensions error in installing ruby gems

I installed a ruby version as below
$ rvm install ruby-1.9.3-p448-dev
and when i checked version as below
$ ruby -v
ruby 1.9.3p448 (2013-06-27 revision 41675) [i686-linux]
But when i tried to install travis like below
$ gem install travis
Building native extensions. This could take a while...
ERROR: Error installing travis:
ERROR: Failed to build gem native extension.
/home/user/.rvm/rubies/ruby-1.9.3-p448/bin/ruby extconf.rb
/home/user/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/fileutils.rb:1371:in `initialize': Permission denied - /home/user/.travis/travis.sh (Errno::EACCES)
from /home/user/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/fileutils.rb:1371:in `open'
from /home/user/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/fileutils.rb:1371:in `block in copy_file'
from /home/user/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/fileutils.rb:1370:in `open'
from /home/user/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/fileutils.rb:1370:in `copy_file'
from /home/user/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/fileutils.rb:477:in `copy_file'
from /home/user/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/fileutils.rb:396:in `block in cp'
from /home/user/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/fileutils.rb:1515:in `block in fu_each_src_dest'
from /home/user/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/fileutils.rb:1529:in `fu_each_src_dest0'
from /home/user/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/fileutils.rb:1513:in `fu_each_src_dest'
from /home/user/.rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/fileutils.rb:395:in `cp'
from extconf.rb:5:in `<main>'
Gem files will remain installed in /home/user/.rvm/gems/ruby-1.9.3-p448/gems/travis-1.5.2 for inspection.
Results logged to /home/user/.rvm/gems/ruby-1.9.3-p448/gems/travis-1.5.2/completion/gem_make.out
So how to avoid the above native extensions error and install the travis succesfully using gem
Edit
When i tried the command by including sudo as below
sudo gem install travis
I am getting the below message as success
Building native extensions. This could take a while...
Successfully installed travis-1.5.2
1 gem installed
Installing ri documentation for travis-1.5.2...
Installing RDoc documentation for travis-1.5.2...
And now what all i am trying to do is to set up environ variables on travis
and hence i tried the following command
$ travis encrypt -r travis_uname/app_name EMAIL_HOST_KEY=key_value
and getting the below wierd error
/usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:247:in `to_specs': Could not find travis (>= 0) amongst [addressable-2.3.5, backports-3.3.3, bundler-1.3.5, bundler-unload-1.0.1, coderay-1.0.9, ethon-0.6.0, faraday-0.8.8, faraday_middleware-0.9.0, ffi-1.9.0, gh-0.11.3, highline-1.6.19, launchy-2.3.0, method_source-0.8.2, mime-types-1.24, multi_json-1.7.9, multipart-post-1.2.0, net-http-persistent-2.9, net-http-pipeline-1.0.1, netrc-0.7.7, pry-0.9.12.2, pusher-client-0.3.1, rake-10.1.0, ruby-hmac-0.4.0, rubygems-bundler-1.2.2, rubygems-update-2.0.7, rvm-1.11.3.8, slop-3.4.6, typhoeus-0.6.4, websocket-1.0.7, websocket-native-1.0.0] (Gem::LoadError)
from /usr/lib/ruby/vendor_ruby/1.8/rubygems/dependency.rb:256:in `to_spec'
from /usr/lib/ruby/vendor_ruby/1.8/rubygems.rb:1208:in `gem'
from /usr/local/bin/travis:18
So finally how to avoid above error and make the above travis command work successfully ?
First of all, set the Ruby version you are using as a default
rvm use --default ruby-1.9.3-p448-dev
and uninstall the gem previously installed with sudo
sudo gem uninstall travis
this makes sure that all your commands are using the same Ruby version and your machine is clean again. Now to your installation problem. This error
Permission denied - /home/user/.travis/travis.sh (Errno::EACCES)
shows you, that the installer tried to access /home/user/.travis but wasn't able to do so due to a lack of user permissions. This means you need to make sure that the folder belongs to you and is writeable
chown -R `whoami` ~/.travis
chmod -R u+wx ~/.travis
Now go ahead and try to re-install:
gem install travis
and everything should be fine.
Installing the -dev packages fixed it for me...
sudo apt-get install ruby-dev
It happens sometimes when you install some gems with sudo and other not.
Ideally you should never sudo for the gem install.
So if you have several gems owned by root and you want to remove the ruby installation and the related gems, run this command:
sudo rvm remove ruby-2.0.0-p353 --gems
rvm remove is the preferred way of removing rubies from rvm. By default, not only will it remove the ruby and it's source files, it will also get rid of aliases, wrappers, environments and any associated binaries - in other words, it cleans up most of the install.
The --gems flag will get rid of all associated gemsets.
The you should reinstall your ruby version with:
rvm install ruby-2.0.0-p353
and bundle install again.

Error installing Heroku Toolbelt

Tried to install Heroku Toolbelt but now I get a Gem:LoadError error when trying to issue any heroku command.
$ heroku -v
/Users/xyz/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in
`to_specs': Could not find heroku (>= 0) amongst [...]
(Gem::LoadError)
$ which heroku
/Users/xyz/.rvm/gems/ruby-1.9.3-p194#global/bin/heroku
It seems it's still seeking the gem, but I already uninstalled it. How can I fix this?
(OSX Mountain Lion)
I might be misunderstanding the issue, but if it is just that the heroku gem is not installed/missing try:
$ gem install heroku
I had the same issues initially with ROR on Windows/OS X.(Everyone suggested me to move to LINUX/UNIX)
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 you can use it easily.

Gem::LoadError installing ruby 1.9.2, in macbook snow leopard

I have been trying to install and run rubyonrails in my macbook Snow Leoppard 10.6.8, with Ruby 1.9.2-p290.
When I write bundle install im having this problem, not just with Postgres also with SQLite and MySQL.
Installing pg (0.11.0) /Users/felipevelasquez/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:585:in initialize': Permission denied -/Users/felipevelasquez/.rvm/gems/ruby-1.9.2-p290/gems/pg-0.11.0/Rakefile` (Errno::EACCES)
When I write sudo bundle install I have this:
/Users/felipevelasquez/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/site_ruby/1.9.1/rubygems/dependency.rb:247:in `to_specs': Could not find bundler (>= 0) amongst [mime-types-1.16, minitest-1.6.0, rack-1.3.2, rake-0.8.7, rdoc-2.5.8, rest-client-1.6.7, sequel-3.20.0, sinatra-1.0, sqlite3-1.3.4, sqlite3-ruby-1.3.3, taps-0.3.23] (Gem::LoadError)
Cause of this problem is this: this could be a rvm bug, I have experienced too earlier.
the directory to write has no permission, while you escalating the privilege, the gem env and PATH info is not passed into it.
You can either try to install rvm and ruby. OR export your env and path with sudo command. for example:
sudo export GEM_HOME = /path/to/gem_home && bundle install

Resources