While trying to run a rails app, I am getting the following error
rails s -p 5000
/home/user/.rvm/gems/ruby-2.1.6/gems/tlsmail-0.0.1/lib/net/smtp.rb:806: warning: already initialized constant Net::SMTPSession
/home/user/.rvm/gems/ruby-2.1.6/gems/tlsmail-0.0.1/lib/net/smtp.rb:806: warning: previous definition of SMTPSession was here
/home/user/.rvm/gems/ruby-2.1.6/gems/tlsmail-0.0.1/lib/net/pop.rb:687: warning: already initialized constant Net::POP
/home/user/.rvm/gems/ruby-2.1.6/gems/tlsmail-0.0.1/lib/net/pop.rb:687: warning: previous definition of POP was here
/home/user/.rvm/gems/ruby-2.1.6/gems/tlsmail-0.0.1/lib/net/pop.rb:688: warning: already initialized constant Net::POPSession
/home/user/.rvm/gems/ruby-2.1.6/gems/tlsmail-0.0.1/lib/net/pop.rb:688: warning: previous definition of POPSession was here
/home/user/.rvm/gems/ruby-2.1.6/gems/tlsmail-0.0.1/lib/net/pop.rb:689: warning: already initialized constant Net::POP3Session
/home/user/.rvm/gems/ruby-2.1.6/gems/tlsmail-0.0.1/lib/net/pop.rb:689: warning: previous definition of POP3Session was here
/home/user/.rvm/gems/ruby-2.1.6/gems/tlsmail-0.0.1/lib/net/pop.rb:702: warning: already initialized constant Net::APOPSession
/home/user/.rvm/gems/ruby-2.1.6/gems/tlsmail-0.0.1/lib/net/pop.rb:702: warning: previous definition of APOPSession was here
/home/user/.rvm/gems/ruby-2.1.6/gems/bundler-1.11.2/lib/bundler/runtime.rb:80:in `rescue in block (2 levels) in require': There was an error while trying to load the gem 'activeadmin'. (Bundler::GemRequireError)
What causes a Gem Require error in bundler?
I hope its trying to load activeadmin
May be the problem in activeadmin
check the gemfile and installation
gem 'activeadmin'
Use this to install activeadmin : Active admin install with Rails 4
It seems like you have multiple versions of the gem tlsmail being installed/loaded. That is the reason, you get the warning of it being already initialized. What you can do is run:
gem list --local | grep 'tlsmail'
which will return a list of versions of the gem installed. Then you can remove one of the versions (as per the dependency of your project) and see if that works.
gem uninstall tlsmail -v <version>
You might also want to check, whether you have same gem with different versions in the Gemfile.
Hope that helps!
Did you initialize your gemset? (Because you're using RVM)
Initialize your gemset as follows before running server,
rvm use ruby-2.3.0#rails425
replace the version of ruby and the name of gemset with your version of ruby and name of gemset.
Related
I've just set up a Linux Mint box for rails development with rvm. I went ahead and generated a Rails 5 app, set up the mysql connection, added the cucumber-rails gem and then tried to run:
rake cucumber
For some reason, I was met with:
/usr/bin/ruby2.3 -S bundle exec cucumber --profile default
/usr/lib/ruby/vendor_ruby/json/version.rb:3: warning: already initialized constant JSON::VERSION
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/version.rb:3: warning: previous definition of VERSION was here
/usr/lib/ruby/vendor_ruby/json/version.rb:4: warning: already initialized constant JSON::VERSION_ARRAY
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/version.rb:4: warning: previous definition of VERSION_ARRAY was here
/usr/lib/ruby/vendor_ruby/json/version.rb:5: warning: already initialized constant JSON::VERSION_MAJOR
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/version.rb:5: warning: previous definition of VERSION_MAJOR was here
/usr/lib/ruby/vendor_ruby/json/version.rb:6: warning: already initialized constant JSON::VERSION_MINOR
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/version.rb:6: warning: previous definition of VERSION_MINOR was here
/usr/lib/ruby/vendor_ruby/json/version.rb:7: warning: already initialized constant JSON::VERSION_BUILD
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/version.rb:7: warning: previous definition of VERSION_BUILD was here
/usr/lib/ruby/vendor_ruby/json/common.rb:99: warning: already initialized constant JSON::NaN
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/common.rb:99: warning: previous definition of NaN was here
/usr/lib/ruby/vendor_ruby/json/common.rb:101: warning: already initialized constant JSON::Infinity
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/common.rb:101: warning: previous definition of Infinity was here
/usr/lib/ruby/vendor_ruby/json/common.rb:103: warning: already initialized constant JSON::MinusInfinity
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/common.rb:103: warning: previous definition of MinusInfinity was here
/usr/lib/ruby/vendor_ruby/json/common.rb:128: warning: already initialized constant JSON::UnparserError
/var/lib/gems/2.3.0/gems/json-1.8.5/lib/json/common.rb:128: warning: previous definition of UnparserError was here
This is, to my knowledge, a fairly plain vanilla installation, so I cannot understand what I've done to earn these warnings. Do I somehow have conflicting gems in place? If so, how do I resolve this?
I managed to get rid of the JSON warnings by:
bundle clean --force
bundle
The json gem that came with your version of Ruby is a little outdated. If you want to get rid of these warnings, you have to include a more up to date version of it in your Gemfile:
gem 'json', '>= 2.0.0'
Then run bundle install.
redshift5's answer worked for me. Just to add more context.
I had this same issue while working on an application with Rails 6.
I was getting warnings like this:
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/version.rb:4: warning: already initialized constant JSON::VERSION
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/version.rb:4: warning: previous definition of VERSION was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/version.rb:5: warning: already initialized constant JSON::VERSION_ARRAY
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/version.rb:5: warning: previous definition of VERSION_ARRAY was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/version.rb:6: warning: already initialized constant JSON::VERSION_MAJOR
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/version.rb:6: warning: previous definition of VERSION_MAJOR was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/version.rb:7: warning: already initialized constant JSON::VERSION_MINOR
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/version.rb:7: warning: previous definition of VERSION_MINOR was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/version.rb:8: warning: already initialized constant JSON::VERSION_BUILD
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/version.rb:8: warning: previous definition of VERSION_BUILD was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/common.rb:100: warning: already initialized constant JSON::NaN
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/common.rb:130: warning: previous definition of NaN was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/common.rb:102: warning: already initialized constant JSON::Infinity
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/common.rb:132: warning: previous definition of Infinity was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/common.rb:104: warning: already initialized constant JSON::MinusInfinity
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/json-2.5.1/lib/json/common.rb:134: warning: previous definition of MinusInfinity was here
/home/promisechukwuenyem/.rbenv/versions/2.7.2/lib/ruby/2.7.0/json/common.rb:129: warning: already initialized constant JSON::UnparserError
Things I tried:
I tried removing my Gemfile.lock file and trying to do a fresh bundle install but that did not fix it.
I tried to uninstall all gem versions of puma and jsonapi-serializer from my computer and reinstalling them, but that did not fix it.
Here's how I fixed:
First I ran the command below to force clean up unused gems in the bundler directory even if --path is set:
bundle clean --force
Next, I ran the command below to reinstall my gems for the project:
bundle install
OR
bundle update
OR
bundle update --force
That's all.
I hope this helps.
I'm using using letsrate gem and getting the following error:
ArgumentError - wrong number of arguments (3 for 2):
lib/letsrate/lib/letsrate/model.rb:69:in `letsrate_rateable'
app/models/model_definition.rb:3:in `<class:ModelDefinition>'
app/models/model_definition.rb:1:in `<top (required)>'
I've tried to downgrade version from 1.0.9 to 1.0.8 and then I've copied the source to lib directory still I'm getting the same error.
The code shown in the master branch of the letsrate gem shows that the method in question accepts a variable number of arguments.
Try installing the gem from the master branch of GitHub to correct the problem. Add this code to your Gemfile and run bundle install
gem 'letsrate', git: '/muratguzel/letsrate'
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/i686-linux/psych.so: warning: already initialized constant ANY
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/i686-linux/psych.so: warning: already initialized constant UTF8
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/i686-linux/psych.so: warning: already initialized constant UTF16LE
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/i686-linux/psych.so: warning: already initialized constant UTF16BE
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:12: warning: already initialized constant ANY
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:15: warning: already initialized constant UTF8
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:18: warning: already initialized constant UTF16LE
/usr/share/ruby-rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/psych/nodes/stream.rb:21: warning: already initialized constant UTF16BE
i got this error when i strated my rails server for the first time after creating a new rails project. could anyone help me out of this
The fix for me was simply to do gem uninstall psych.
Perhaps the solution described on this gist will help:
rvm use 1.9.3
gem uninstall psych
gem install psych
give me solution for this
when i'm running rake db:create
it is showing warning like these
DEPRECATION WARNING: railtie_name is deprecated and has no effect. (called from <class:Engine> at /home/shajin/.rvm/gems/ruby-1.9.2-p0/bundler/gems/spree_paypal_express-073f2f814dd8/lib/spree_paypal_express.rb:5)
WARNING: 'require 'rake/rdoctask'' is deprecated. Please use 'require 'rdoc/task' (in RDoc 2.4.2+)' instead.
at /home/shajin/.rvm/gems/ruby-1.9.2-p0/gems/rake-0.9.2.2/lib/rake/rdoctask.rb
WARNING: Global access to Rake DSL methods is deprecated. Please include
... Rake::DSL into classes and modules which use the Rake DSL methods.
WARNING: DSL method Soletronspree::Application#task called at /home/shajin/.rvm/gems/ruby-1.9.2-p0/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks'
WARNING: 'task :t, arg, :needs => [deps]' is deprecated. Please use 'task :t, [args] => [deps]' instead.
at /home/shajin/.rvm/gems/ruby-1.9.2-p0/gems/deface-0.5.2a/tasks/deface.rake:3:in `block in <top (required)>'
soletronspree_test already exists
soletronspree_development already exists
First of all try updating your gems, specifically spree_paypal_express.
bundle update
It is currently locked at 073f2f814dd8... and according to GitHub that SHA1 hash points to a 6 months old commit.
If you are currently not using the latest from the git repository, try them out by changing the gem line to this:
gem "spree_paypal_express", :git => "git://github.com/spree/spree_paypal_express.git"
The latest paypal extension release depends on Spree 1.0.0 or later. To install 1.0.0 change your current spree gem line to this:
gem 'spree', '1.0.0'
and run bundle update
Keep in mind, that updating Spree may break previous functionality elsewhere.
But it's always a great idea to stay up-to-date to have all the newest features.
When running Rails 3 RC with Ruby 1.9.2.rc2 under RVM I keep getting a very large number of errors from the MySQL driver bundle that look like this:
/opt/local/rvm/gems/ruby-1.9.2-rc2/gems/mysql-2.8.1/lib/mysql_api.bundle: warning: already initialized constant MysqlRes
/opt/local/rvm/gems/ruby-1.9.2-rc2/gems/mysql-2.8.1/lib/mysql_api.bundle: warning: already initialized constant MysqlField
/opt/local/rvm/gems/ruby-1.9.2-rc2/gems/mysql-2.8.1/lib/mysql_api.bundle: warning: already initialized constant MysqlError
/opt/local/rvm/gems/ruby-1.9.2-rc2/gems/mysql-2.8.1/lib/mysql_api.bundle: warning: already initialized constant VERSION
/opt/local/rvm/gems/ruby-1.9.2-rc2/gems/mysql-2.8.1/lib/mysql_api.bundle: warning: already initialized constant OPT_CONNECT_TIMEOUT
/opt/local/rvm/gems/ruby-1.9.2-rc2/gems/mysql-2.8.1/lib/mysql_api.bundle: warning: already initialized constant OPT_COMPRESS
/opt/local/rvm/gems/ruby-1.9.2-rc2/gems/mysql-2.8.1/lib/mysql_api.bundle: warning: already initialized constant OPT_NAMED_PIPE
/opt/local/rvm/gems/ruby-1.9.2-rc2/gems/mysql-2.8.1/lib/mysql_api.bundle: warning: already initialized constant INIT_COMMAND
This shows up in rails console and unit tests, anything that requires the full Rails stack, but not a script that uses Sequel directly in the same environment.
Although the bundle itself does load and the MySQL driver does work, this enormous pile of warnings prefaces anything run through Rails. Usually this results from a redundant load of the mysql gem somewhere within the Rails environment. The gem is declared in the Gemfile:
gem 'rails', '3.0.0.rc'
gem 'haml'
gem 'sequel'
gem 'mysqlplus'
gem 'mysql'
I'd suppose this is the Rails autoloader failing to understand the Mysql library has already been loaded, and loading it again. Is there an easy way to fix this?
Update:
Load mysql or mysqlplus but not both at the same time or you will get warnings like this. mysqlplus includes all of the functionality of mysql and is a dependency of Sequel.
Do you need the mysqlplus gem? I am using Rails 3 with only mysql 2.8.1:
gem 'mysql', '2.8.1'
Although I have not used mysqlplus, I am guessing that it sets the constants you are seeing in the warnings, and then the mysql gem sets these constants again when it is loaded.
UPDATE: Use mysql2 instead
#gem 'mysql', '2.8.1'
gem 'mysql2'
You also need to update your database adapters in database.yml:
development:
#adapter: mysql
adapter: mysql2
database: somedatabase_development