I have an application running on thin 1.2.11 behind nginx. I was trying to update my application to the latest version of it's gems using bundle update on a development machine, commiting to git, then running cap deploy. However, thin is giving me the following error:
/usr/local/lib/ruby/gems/1.9.1/gems/bundler-1.0.14/lib/bundler/runtime.rb:31:in `block in setup': You have already activated rack 1.3.0, but your Gemfile requires rack 1.2.3. Consider using bundle exec. (Gem::LoadError)
On the server I have the following gems installed system wide:
bundler (1.0.14)
daemons (1.1.3)
eventmachine (0.12.10)
rack (1.3.0)
rake (0.9.2)
thin (1.2.11)
My Gemfile for my aplication:
source 'http://rubygems.org'
gem 'rails', '3.0.7'
gem 'sqlite3'
gem 'capistrano'
gem 'thin'
gem 'RedCloth'
gem 'will_paginate', '3.0.pre2'
gem 'jquery-rails'
I believe thin is requiring rack 1.3, while something in my Gemfile is requiring rack 1.2.3. Am I managing my gems the wrong way? What is the proper way to manage deployment and proper gem control?
I found using bundle exec thin start works, but I prefer a solution to allow me to use /etc/init.d/thin start.
Please read this: http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/ before you tell us what you prefer.
Problem is you prefer to run command from gem installed into system to run application which has it's own dependencies (i.e. rack) specified in Gemfile. You can't have two version of same library loaded at the same time, so it's causing your problem with needing 'bundle exec' in from on every command.
Just do bundle exec at start of your cap scripts and he will pickup gems from bundler.
Often I have same problem if i have in system / currently used gemset newer versions of some gems.
i even have alias called be in shell for bundle exec. New versions of rvm do bundle exec automagicly also :).
Related
I am trying to use VS Code for debugging a Ruby on Rails application. I have installed both the Ruby and Rubocop extension into VS Code. Then I have installed ruby-debug-ide -v 0.6.0 and debase -v 0.2.1 both via sudo gem install and rvmsudo gem install. However, when trying to debug the application using Rails server, I get the following exception:
/usr/lib/ruby/2.3.0/rubygems/dependency.rb:319:in `to_specs'
:
Could not find 'ruby-debug-ide' (>= 0.a) among 48 total gem(s)
(
Gem::LoadError
)
Checked in 'GEM_PATH=/home/myname/.rvm/gems/ruby-2.3.1:/home/myname/.rvm/gems/ruby-2.3.1#global', execute `gem env` for more information
from /usr/lib/ruby/2.3.0/rubygems/dependency.rb:328:in `to_spec'
from /usr/lib/ruby/2.3.0/rubygems/core_ext/kernel_gem.rb:65:in `gem'
from /usr/local/bin/rdebug-ide:22:in `<main>'
However, when I list all installed gems with rvm all do gem list, neither of the installed gems are there:
*** LOCAL GEMS ***
...
concurrent-ruby (1.0.2)
did_you_mean (1.0.0)
erubis (2.7.0)
...
rdoc (4.2.1)
rubygems-bundler (1.4.4)
rvm (1.11.3.9)
...
Does anybody know how to fix this?
In my case, the solution was quite simple. As a newbie in Ruby on Rails, I did not realize that instead of installing gems into Ruby root, I should specify them in my Gemfile. So, inside Gemfile I put only:
group :development do
gem 'ruby-debug-ide', '0.6.0'
gem 'debase', '0.2.1'
gem 'web-console', '~> 2.0'
gem 'spring'
end
and this solved the issue for me.
I also had this issue for a while, there doesn't seem to be a clear cut way of resolving this problem. All I had to do was run vs code through the terminal and I could debug my rails project, assuming you are using Linux. Just make sure you don't open vs code via a shortcut.
Trying to install Devise and I get the following message "Could not find generator devise:install."
leigh#leigh-VirtualBox:~/Projects/dev01$ bundle install
Using rake 10.3.2
Using i18n 0.6.11
Using json 1.8.1
Using minitest 5.4.0
Using thread_safe 0.3.4
Using tzinfo 1.2.1
Using activesupport 4.1.4
Using builder 3.2.2
Using erubis 2.7.0
Using actionview 4.1.4
Using rack 1.5.2
Using rack-test 0.6.2
Using actionpack 4.1.4
Using mime-types 1.25.1
Using polyglot 0.3.5
Using treetop 1.4.15
Using mail 2.5.4
Using actionmailer 4.1.4
Using activemodel 4.1.4
Using arel 5.0.1.20140414130214
Using activerecord 4.1.4
Using execjs 2.2.1
Using autoprefixer-rails 2.1.1.20140710
Using bcrypt 3.1.7
Using sass 3.2.19
Using bootstrap-sass 3.2.0.0
Using thor 0.19.1
Using railties 4.1.4
Using bootswatch-rails 3.2.0
Using coffee-script-source 1.7.1
Using coffee-script 2.3.0
Using coffee-rails 4.0.1
Using data-confirm-modal 1.0.1 from git://github.com/ifad/data-confirm-modal.git (at master)
Using declarative_authorization 0.5.7
Using orm_adapter 0.5.0
Using warden 1.2.3
Using devise 3.2.4
Using hike 1.2.3
Using multi_json 1.10.1
Using jbuilder 2.1.3
Using jquery-rails 3.1.1
Using bundler 1.6.4
Using tilt 1.4.1
Using sprockets 2.11.0
Using sprockets-rails 2.1.3
Using rails 4.1.4
Using rdoc 4.1.1
Using sass-rails 4.0.3
Using sdoc 0.4.0
Using spring 1.1.3
Using sqlite3 1.3.9
Using turbolinks 2.2.2
Using uglifier 2.5.3
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
leigh#leigh-VirtualBox:~/Projects/dev01$ rails generate devise:install
Could not find generator devise:install.
leigh#leigh-VirtualBox:~/Projects/dev01$
My Gemfile is:
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.1.4'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.3'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring', group: :development
gem 'bootstrap-sass', '~> 3.2.0.0'
gem 'bootswatch-rails', '~> 3.2.0'
gem 'autoprefixer-rails'
# Use data-confirm-modal to create custom alert modal popups
gem 'data-confirm-modal', github: 'ifad/data-confirm-modal'
# Use devise for user authentication
gem 'devise'
# Use declarative_authorization for user authorisation
gem 'declarative_authorization'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
# Use debugger
# gem 'debugger', group: [:development, :test]
Rails version is:
leigh#leigh-VirtualBox:~/Projects/dev01$ rails -v
Rails 4.1.4
leigh#leigh-VirtualBox:~/Projects/dev01$
OS version is:
leigh#leigh-VirtualBox:~/Projects/dev01$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 14.04 LTS
Release: 14.04
Codename: trusty
leigh#leigh-VirtualBox:~/Projects/dev01$
Any ideas as to why the Devise gem won't install after correctly adding it to the Gemfile and running the bundle install?
I did have the server running at one point (rails server) and saw an article stating that attempting to install Devise whilst the server is up could cause strange issues.
I've since tried again with the server down but no difference. I'm sure this is probably happening due to something really simple that I overlooked in the setup, just not sure where else to look.
Any advise or suggestions on where to look next would be great, thanks.
I've done testing using the command below but still received the same error:
leigh#leigh-VirtualBox:~/Projects/dev01$ bundle exec rails g devise:install
Could not find generator devise:install.
The list of installed generators are below and Devise is not listed, how do I get it listed?
leigh#leigh-VirtualBox:~/Projects/dev01$ rails generate
Usage: rails generate GENERATOR [args] [options]
General options:
-h, [--help] # Print generator's options and usage
-p, [--pretend] # Run but do not make any changes
-f, [--force] # Overwrite files that already exist
-s, [--skip] # Skip files that already exist
-q, [--quiet] # Suppress status output
Please choose a generator below.
Rails:
assets
controller
generator
helper
integration_test
jbuilder
mailer
migration
model
resource
scaffold
scaffold_controller
task
Coffee:
coffee:assets
Jquery:
jquery:install
Js:
js:assets
TestUnit:
test_unit:generator
test_unit:plugin
leigh#leigh-VirtualBox:~/Projects/dev01$
same problem today, I removed the 'spring' out from the Gemfile and it did the trick.
or you can turn off your spring first and run rails generate devise:install
OK, I'm still not 100% sure why this worked or what caused the issue in the first place but after running the following commands:
leigh#leigh-VirtualBox:~/Projects/dev01$ gem uninstall devise
Successfully uninstalled devise-3.2.4
leigh#leigh-VirtualBox:~/Projects/dev01$ gem uninstall warden
Successfully uninstalled warden-1.2.3
leigh#leigh-VirtualBox:~/Projects/dev01$ bundle install
Fetching gem metadata from https://rubygems.org/.........
Fetching additional metadata from https://rubygems.org/..
[... text removed ...]
Installing warden 1.2.3
Installing devise 3.2.4
[... text removed ...]
Your bundle is complete!
Use `bundle show [gemname]` to see where a bundled gem is installed.
leigh#leigh-VirtualBox:~/Projects/dev01$ rails generate devise:install
create config/initializers/devise.rb
create config/locales/devise.en.yml
Woo Hoo!!! problem solved. Great way to waste a couple of days :-(
What worked for me was:
$ sudo -s
$ bundle exec rails generate devise:install
Without sudo or running the "initializer" /bin/bash --login didn't work. The other solution could be to remove the Gemfile.lock and run bundle install again.
This seems to work on my machine under RVM, but that's with a fresh gemset. If you're using version of Ruby (or an RVM gemset) shared with other Rails installs, you could be having problems there.
As you're using Bundler you should probably use:
bundle exec rails g devise:install
as a general precaution, to ensure you're using the bundle's gems.
I fixed it by adding the following line to my Gemfile:
gem 'devise'
After adding that line, I executed bundle install.
I had the same problem today. I tried uninstalling devise and warden but no luck. Finally I deleted the Gemfile.lock and ran bundle install again and that did the trick.
This will sound ridiculous but open a new terminal window and try again. That's what it ended up being for me. If that still doesn't work, try:
DISABLE_SPRING=1 bundle exec rails g devise:install
I had the same problem today in vscode terminal, try remove the gemfile.lock and if doesn't work, repeate the below process.
You can remove de gemfile and after try bundle install on a new terminal.
I'm think this is a permission problem on vscode.
In first step you can remove the line of devise on gemfile and add again manually -> gemfile 'devise'
Steps:
1.0 try on your terminal.
1.1 remove gemfile.lock.
1.2 run bundle install.
1.3 run rails g devise:install.
If doesn't work
2.0 Quit the terminal e open a new.
2.1 try run the same steps on 1.1 to 1.3
Solved to me.
In my case, I was using:
gem 'rack-cors', :require 'rack-cors'
Then I got the same error but none of the solutions here solved it.
I had to replace it just to be like this:
gem 'rack-cors'
then run
$ bundle install
$ rails generate devise:install
I close my terminal and open a new one.
Then rails generate devise:install
It works this time. It is so weired!
Restarting the console will fix this issue.
I am currently running one of my Rails applications on version 3.1.3. My gemfile always listed:
gem 'rails', '3.1.3'
This worked just fine. In an effort to move to 3.1.10, I changed my Gemfile to the following:
gem 'rails', '~> 3.1.10'
Surprisingly, things break when I run bundle update rails after that change:
Bundler could not find compatible versions for gem "multi_json":
In Gemfile:
twitter (>= 0) ruby depends on
multi_json (~> 1.3) ruby
fnordmetric (>= 0) ruby depends on
multi_json (1.2.0)
Just as a test, I tried changing the gem version to '>= 3.1.0' and that installed without any quims, albeit it went to 3.2, which I'm not ready for just yet on this particular application.
Any suggestions for getting this thing running on 3.1.10 which was released today to address a security vulnerability?
Also an update:
I am having absolutely no trouble stashing Gemfile.lock away and starting from Rails 3.1.4. As soon as I try to go to 3.1.5+, this is where all the trouble begins.
Make the change in your Gemfile to
gem 'rails', '3.1.10'
Then try running
bundle update
instead of
bundle install
I can't see your Gemfile but this should will allow the bundler to try and find compatible Gem matches. If you have hard code a Gem revision you might have to relax it and repeat the update. Good luck!
Looking at the gems, it appears that oauth2 lists "multi_json ~> 1.0" and ActiveSupport 3.1.10 lists "multi_json < 1.3, >= 1.0" as the dependencies, so that should resolve. I've run into strangeness like this and fixed it by running
gem uninstall <relevant gems>
then running bundle install again. So maybe try
gem uninstall oauth2 multi_json activesupport
then bundle install
Edit
gem uninstall twitter multi_json fnordmetric
When I add has_secure_password to the model (inherited from ActiveRecord::Base), error stating that "bcrypt-ruby is not part of the bundle" occurs.
Here the log is:
Started GET "/users" for 127.0.0.1 at 2012-02-19 16:37:12 +0900
Gem::LoadError (bcrypt-ruby is not part of the bundle. Add it to Gemfile.):
app/models/user.rb:3:in `<class:User>'
app/models/user.rb:1:in `<top (required)>'
app/controllers/users_controller.rb:1:in `<top (required)>'
I installed bcrypt-ruby by
$ gem install bcrypt-ruby
Building native extensions. This could take a while...
1 gem installed
Installing YARD (yri) index for bcrypt-ruby-3.0.1...
Installing RDoc documentation for bcrypt-ruby-3.0.1...
but was no avail.
I tried
$ bundle exec rails server
but was no help.
If I comment out the line "has_secure_password", this error does not come out.
How can I solve this problem?
I already had gem 'bcrypt-ruby', '~> 3.0.0' in Gemfile, and had already ran the command bundle, and yet I still got that message. The problem was that I forgot to restart the server:
touch tmp/restart.txt
As the message says you need to add bcrypt-ruby to your Gemfile (at the root of the project).
Adding
gem "bcrypt-ruby"
and then running bundle install should do the trick (this would fetch the gem if you hadn't already installed it).
You can specify specific versions to, eg
gem "bcrypt-ruby", "~> 3.0.1"
will get you the latest version that is >= to 3.0.1 but less than 3.1. You might do this if 3.0.1 has a bug fix you depend on and you're happy to get more bug fixes but you don't want major changes. There's loads more info on the bundler website.
In your Gemfile add a line
gem 'bcrypt-ruby'
and then from the command line
bundle install
Something that came up for me that is not addressed here yet. I got this error after going to a new system on which I installed Ruby 2.0.x.
It turns out that even if I was using the new bcrypt 3.1.7 it didn't work for me until I ALSO had bcrypt-ruby 3.0.1 in the gemfile. I resisted that when I should have just taken the error at it's word.
gems:
bcrypt (3.1.7 ruby x86-mingw32)
bcrypt-ruby (3.0.1 x86-mingw32, 3.0.0)
gemfile:
gem 'bcrypt-ruby', '~> 3.0.1'
gem 'bcrypt', '~> 3.1.7'
Before adding both I tried all sorts of single version combinations.
Restart the server and reinstall bundle in correct order, that is:
bundle install, bundle update, bundle install
and then server restart.
If you already put the gem in the gem file and bundle installed and you are still getting an error then restart your server.
I have several Rails applications with version 2.3.8, which I run using the thin server. I want to install Rails 3.0.1 on the same machine for testing purposes.
The installation worked fine, but after installing Rails 3.0.1, running Rails 2.3.8 applications with thin fails with this error:
>> Using rails adapter
Missing the Rails 2.3.8 gem. Please `gem install -v=2.3.8 rails`,
update your RAILS_GEM_VERSION setting in config/environment.rb for
the Rails version you do have installed, or comment out RAILS_GEM_VERSION
to use the latest version installed.
There seems to be a problem with the latest version of rack (1.2.1) installed with Rails 3. If I uninstall rack 1.2.1 and keep only rack 1.1.0, my Rails 2.3.8 applications run with no problem.
Specifying the rack version with config.gem in environment.rb doesn't solve the problem. Unpacking the rack 1.1.0 gem in the vendor/gems directory doesn't change anything either.
With rack 1.2.1, I can't start my Rails 2.3.8 applications. Without rack 1.2.1, I can't start my Rails 3.0.1 applications.
All the solutions I've found online are about unpacking the rack gem, but this doesn't seem to work for me. Is there something else I should be doing?
I have just Ruby 1.9.2p0 installed using RVM system wide and I run apps using Rails 3 & 2.3.10 on the same server using Thin.
You have to setup bundler on your rails 2.3.10 apps (http://gembundler.com/rails23.html).
Here's one of my Gemfiles for a Rails 2.3.10 app. It's important to specify the rack version.
source :gemcutter
gem "rack", "~> 1.1.0"
gem "rails", "~> 2.3.10"
gem "will_paginate", "~> 2.3.15"
gem 'haml'
gem 'mysql2'
gem 'authlogic'
gem 'searchlogic'
gem 'paperclip'
gem 'thin'
For Rails 2.3.10 you have to start thin from in the app directory using:
bundle exec thin start <options here>
If you are using RVM and are trying to start apps from an init script read this: RVM and thin, root vs. local user
Had the same issue with a Rails 2.3.5 app and Thin (1.2.7).
Had to:
gem uninstall rack --version 1.2.1
gem uninstall rack --version 1.1.0
that left me with only version 1.0.1 and then it worked fine.
Like you, I'm going to be in a mess trying to transition an app into Rails 3. One solution is to use rvm (which I already am) and its notion of gemsets which provide isolation for specific gems for specific applications. I've not played with those yet.
Hopefully the 'thin' folks will get this sorted out.
I did manage to run both Rails versions by installing Ruby twice in separate locations.
If anyone finds a way to run with only one Ruby though, I'd be interested to know.