Reputation: 143
I have started getting the following error when I try to run 'rails s' on my local machine:
You've tried to invoke Spring when it's already loaded (i.e. the Spring constant is defined).
This is probably because you generated binstubs with Spring 1.0, and you now have a Spring version > 1.0 on your system. To solve this, upgrade your bundle to the latest Spring version and then run `bundle exec spring binstub --all` to regenerate your binstubs. This is a one-time step necessary to upgrade from 1.0 to 1.1.
Here's the backtrace:
/Users/emmetgibney/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
/Users/emmetgibney/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:55:in `load'
/Users/emmetgibney/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:319:in `block in load'
/Users/emmetgibney/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:291:in `load_dependency'
/Users/emmetgibney/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/activesupport-6.0.2.2/lib/active_support/dependencies.rb:319:in `load'
/Users/emmetgibney/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/spring-2.1.0/lib/spring/binstub.rb:11:in `<main>'
/Users/emmetgibney/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Users/emmetgibney/.rbenv/versions/2.7.0/lib/ruby/2.7.0/rubygems/core_ext/kernel_require.rb:92:in `require'
/Users/emmetgibney/Dropbox/Programming/tableread/tableread/bin/spring:15:in `<top (required)>'
bin/rails:3:in `load'
bin/rails:3:in `<main>'
I have Spring version 2.1.0 installed on my machine. I have run the command the error message asks, bundle exec spring binstub --all
and the error persists. I read on another SO answer to try running bundle exec spring binstub --remove --all
which did remove then binstubs, I then ran the first command again to regenerate them. Still getting the same error.
The problem persists even on other rails apps. For example, when I switch to another app on my machine and run rails s
I get the same error, even though I might not have worked on that app for weeks.
The problem started after installing Docsplit and its required dependencies, along with google-cloud-text_to_speech. Probably worth noting that my system won't allow me to uninstall the google-cloud-text_to_speech gem as well.
I'm using MacOS 10.13.6
Upvotes: 3
Views: 7397
Reputation: 530
Maybe regenerate your gemspecs try running ...
gem pristine --all
bundle install
bundle exec spring binstub --all
Upvotes: 2
Reputation: 51
I had the same after updating my app to rails 6.1.4.1.
Gemfile.lock
bundle install
Upvotes: -1
Reputation: 2077
I have faced this exact situation 30 minutes ago. I'm using ArchLinux. I do have the latest Ruby from the ArchLinux community. But the project I'm working on uses Ruby 2.7, and I'm using RVM for that.
Today suddenly I saw rails s
isn't working. I quickly ran bundle exec spring binstub --all
, but I got:
* bin/rake: Spring already present
* bin/rails: Spring already present
So I read the package update log (/var/log/pacman.log
), and I got this:
[2021-10-20T12:33:44+0530] [ALPM] upgraded libffi (3.3-4 -> 3.4.2-4)
[2021-10-20T12:33:44+0530] [ALPM] upgraded glib2 (2.70.0-1 -> 2.70.0-2)
[2021-10-20T12:33:44+0530] [ALPM] upgraded gobject-introspection-runtime (1.70.0-1 -> 1.70.0-2)
[2021-10-20T12:33:44+0530] [ALPM] upgraded gjs (2:1.68.3-1 -> 2:1.68.3-2)
[2021-10-20T12:33:45+0530] [ALPM] upgraded python (3.9.7-1 -> 3.9.7-2)
[2021-10-20T12:33:45+0530] [ALPM] upgraded gobject-introspection (1.70.0-1 -> 1.70.0-2)
[2021-10-20T12:33:45+0530] [ALPM] upgraded guile (2.2.7-1 -> 2.2.7-2)
[2021-10-20T12:33:45+0530] [ALPM] upgraded libp11-kit (0.24.0-1 -> 0.24.0-2)
[2021-10-20T12:33:45+0530] [ALPM] upgraded p11-kit (0.24.0-1 -> 0.24.0-2)
[2021-10-20T12:33:45+0530] [ALPM] upgraded libfilezilla (0.34.0-1 -> 0.34.1-1)
[2021-10-20T12:33:45+0530] [ALPM] upgraded llvm-libs (12.0.1-4 -> 12.0.1-5)
[2021-10-20T12:33:46+0530] [ALPM] upgraded llvm (12.0.1-4 -> 12.0.1-5)
[2021-10-20T12:33:46+0530] [ALPM] upgraded ocaml-ctypes (0.17.1-6 -> 0.17.1-8)
[2021-10-20T12:33:46+0530] [ALPM] upgraded llvm-ocaml (12.0.1-4 -> 12.0.1-5)
[2021-10-20T12:33:46+0530] [ALPM] upgraded mpg123 (1.29.0-1 -> 1.29.1-1)
[2021-10-20T12:33:46+0530] [ALPM] upgraded python-cffi (1.14.6-1 -> 1.14.6-2)
[2021-10-20T12:33:46+0530] [ALPM] upgraded python-gobject (3.40.1-1 -> 3.40.1-2)
[2021-10-20T12:33:47+0530] [ALPM] upgraded python2 (2.7.18-4 -> 2.7.18-5)
[2021-10-20T12:33:47+0530] [ALPM] upgraded wayland (1.19.0-1 -> 1.19.0-2)
[2021-10-20T12:33:47+0530] [ALPM] upgraded qt5-base (5.15.2+kde+r243-1 -> 5.15.2+kde+r247-1)
[2021-10-20T12:33:48+0530] [ALPM] upgraded qscintilla-qt5 (2.13.0-1 -> 2.13.1-1)
[2021-10-20T12:33:48+0530] [ALPM] upgraded ruby (3.0.2-1 -> 3.0.2-2)
[2021-10-20T12:33:49+0530] [ALPM] upgraded ruby-docs (3.0.2-1 -> 3.0.2-2)
As you can see there's a libffi
update and the Archlinux community built Ruby, Python, LLVM and even Glibc on the new libffi. So, for RVM ruby's ffi
gem, it was a soname bump.
So I downgraded libffi
and it's working. But this might break the system when you reboot it because glibc is built against the new libffi
. So I have to keep latest libffi and rebuild the ffi gem that the bundler specifies. So this will solve the issue:
$ gem uninstall ffi -aI
# If you have Gemfile
$ bundle install
# If you don't have Gemfile
$ gem install ffi
So libffi
bump was a different reason for the problem. And rebuilding FFI native extension will fix this.
Upvotes: 1
Reputation: 321
Do the following steps:
bundle install
Vendor
file from project.bundle install
.rails s
.Upvotes: 0
Reputation: 11
This happened to me after creating a new rails app with Postgres, running a local server (which worked), upgrading from Ruby 2.7.0 > 2.7.2
, bundling, and trying to run the server again.
I was getting this error over and over (even after running the binstub
command):
You've tried to invoke Spring when it's already loaded ...
This soloved my issue
.bundle
folderbundle install
Upvotes: 1
Reputation: 273
I had the same issue. My problem was I had Postgres installed with homebrew, and then I had Postgres.app installed as well. The Postgres.app version was the one I was running, and the one that would start when I typed psql
into terminal, but rbenv could not access it.
I was able to follow the steps here.
First make sure you have your $PATH
variable set up correctly. If you don't, run
sudo mkdir -p /etc/paths.d &&
echo /Applications/Postgres.app/Contents/Versions/latest/bin | sudo tee /etc/paths.d/postgresapp
and then restart your terminal.
After you have confirmed that or run the command to update it, run
sudo ARCHFLAGS="-arch x86_64" gem install pg
and you should be good to go. Just make sure your config/database.yaml
is setup properly, something like;
development:
adapter: postgresql
database: [YOUR_DATABASE_NAME]
host: localhost
And to finally run rails db:migrate
and rails db:setup
to set up the database and rails server
to start the server, hopefully without issue.
Upvotes: 1
Reputation: 179
In my case it was due to postgres gem in my Gemfile. I was using sqlite3 on my development server and postgres on production (Heroku). So pg gem was without a group wrapper.
I solved it by wrapping postgres with a production group wrapper like so:
group :production do
gem 'pg'
end
Upvotes: 1
Reputation: 1
I ran into the same problem after upgrading from Ubuntu 18.04 to 20.04. The solution in Ruby Forum DID NOT WORK for me with Ruby 2.7.0 and Rails 6.0.3.2
However this How to get FFI working on Ruby 2.7.2 image worked for me.
Basically, this works if it was an upgraded
sudo ln -s /usr/lib/x86_64-linux-gnu/libffi.so.7 /usr/lib/x86_64-linux-gnu/libffi.so.6
Upvotes: 0
Reputation: 143
I managed to solve the problem. When I removed the spring gem and tried to start my rails server I got the following message:
/Users/emmetgibney/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/bootsnap-1.4.6/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require': dlopen(/Users/emmetgibney/.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/pg-1.2.3/lib/pg_ext.bundle, 9): Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib (LoadError)
This made me think it could be a problem with postgres, so I uninstalled and reinstalled postgres using brew, and that seems to have resolved it. I can now start my rails server for this app, and all my other apps as well.
I hadn't done involving postgres since installing it WAY back when, so I have no idea how postgres got messed up in the first place, but it works now nonetheless.
Upvotes: 1