For debugging purposes, I installed bundle gems into a different folder
bundle install --path=.bundle
I want to debug the app modifying the gem sources in this folder, so I need to run my server, and tell rails to use the gems in the special folder
What options do I need to add to rails server in order to produce the desired magic?
How do you do when you need to debug a problem or a mysterious, cryptic behaviour in your rails app that doesn't seem to be due to your codebase?
More precisely, what is the recommended strategy for debugging a gem?
Related
I understand that running the above command will install all of the gems necessary for my rails app to work properly into vendor/bundle. I believe I should then be able to copy the entire app directory to any system that has a compatible version of Ruby running on it and run my app without having to install the gems at a system or user level.
My question is, how do I actually execute that app? From what I gather, I should be able to run:
bundle exec rails s
For the app to look internally for the gems rather than looking to the system to supply them. But, I get the error:
bundler: command not found: rails
I'd like to be able to do this without altering the PATH variable on the host system if possible.
I have a perplexing issue here when trying to implement the Rails Webpacker gem into an existing application.
Unfortunately, I do not have much to offer in the way of debugging information, this is also an internal project, so I have limited options in terms of sharing the entire project source.
I am following the exact steps outlined here: https://github.com/rails/webpacker and have done it multiple times now, but during the bundle exec rails webpacker:install command (after running bundle), I see the message:
Skipped webpack and webpack-dev-server since they already exist.
If you want to overwrite skipped stubs, use --force.
This binstubs most-definitely do not exist in my bin/ directory. Either before or after the webpacker install.
I feel like I have tried everything at this point, and nothing seems to be working:
Reinstalling the gem (multiple versions, even via Git)
Manually creating the binstub from a different project (this "worked" until I tried to run the webpacker:install:react script).
Manually running Yarn, attempting to --force create the binstubs
Tried multiple different configuration tweaks in webpacker.yml
I am just out of ideas at this point. Anything else I should be checking, could try?
This is a fix that worked for me:
I copied these two files into the bin directory of my app and then bundle exec rails webpacker:check_binstubs stopped complaining.
As a side effect it made my app deployable on my Paas with the standard buildpack.
I ran bundle --without development on my machine and now I want to include the dependencies in my development group in my local rails app.
I ran bundle thinking it would including everything again including development, but I receive this message Gems in the groups development were not installed still. Can you tell me the option I need to pass into the bundle command to get the development gems back into my application? I tried running bundle --include development with no luck.
Can you also tell me where you found the option (if thats the solution)? I can't seem to locate a list of bundle options.
If you run
bundle help install
then both the with and without options are documented. Note that without is listed as being a "remembered option" i.e. it is persisted for subsequent calls.
Remembered options are stored in .bundle/config at the root of the project. You can either edit this file directly or view them using
bundle config
Which will also take into account user level configuration or environment variables that affect bundler
I was surprised to confirm this behavior. It seems like the without --development flag is saved, so even if you rm Gemfile.lock, running bundle again will not install the development group. bundle update also doesn't work.
You were close, though, with bundle --include development.
What works is bundle --with development. You don't need to delete your Gemfile.lock before doing this.
When I run a rails console using
rails console
everything is fine.
When I run a rails console using
bundle exec rails console
I get the following warning
Bundler is using a binstub that was created for a different gem.
This is deprecated, in future versions you may need to `bundle binstub my_gem` to work around a system/bundle conflict.
my_gem happens to be a gem that I've created that is completely unrelated and not used in the current project directory.
I've tried every solution in this question with no luck:
Bundler is using a binstub that was created for a different gem
I would appreciate any guidance on removing this warning or help understanding how binstubs work so that I can figure out what's going on.
Nowadays it's common for projects to have "specialized" versions of tools. E.g. in some projects the "rails" command may be expected to be run using "spring" (to start up faster).
So it's not uncommon to generate files in your project's 'bin' directory, and then use those versions when running commands, so e.g. instead of
bundle exec rails console
or
bundle exec spring rails console
you could simply expect the following to work correctly
bin/rails console
and not care whether the project needs spring or bundler or zeus or whatever.
So if you don't have 'bin/rails' in your project, you should generate one that suits the project, e.g. using
bin/rake rails:update:bin
If you don't already have bin/rake, you might have to use
bundle exec rake rails:update:bin
(so your bin/rake commands will also get a speedup from using spring)
Some people even put ./bin in their paths, so whenever they run rake (or whatever) they are actually running ./bin/rake if it exists.
Troubleshooting
for project specific tasks, use bin/* files, creating them if needed (e.g. using special rake tasks like in Rails or using bundle binstub <gemname>) - usually those have Bundler specific lines that will make Bundler happy.
for non-project gems (like your gem), find out where it is (e.g. which mygem) and check out it's contents - it's probably using e.g. "bundler/setup" which is confusing Bundler (because bundler expects a local Gemfile file). Maybe your gem is using bundler (it shouldn't if it's a "global" kind of tool and not a "project" tool).
Also, if you're using them, check if tools like RVM and .rbenv are correctly adding their stuff to your bin files (they usually need to setup specific paths)
If you still have questions, it's best to post the contents of the bin file causing problems - it's meant to be a plain Ruby file, so if there's something wrong, it's usually because of the file contents (and not anything else).
More info: https://github.com/sstephenson/rbenv/wiki/Understanding-binstubs
It happened in a project of mine. Because I ran bundle install with another ruby version.
Make sure your rvm is the correctly ruby version.
As an example, I want to download: https://github.com/banker/newsmonger and tinker with it (to learn Rails). I've downloaded the zip and when I go into that folder and type rails server, the terminal window says to create a new rails app
This is a Rails 2 application, and so as ennuikiller said, you'll need to run script/server.
You may run into problems with dependencies not being installed in this application, which is a problem that normally (now) would be solved with Bundler. Due to this being a Rails 2 application, it doesn't support Bundler out of the box and the owner of the repo hasn't updated it to support that, and so you're dead outta luck there.
What you'll need to do is attempt to run rake gems:install (which may or may not work, depending on the sun's positioning) which will install the gems specified in config/environment.rb and the proper config/environments files using the config.gem methodology. This was how it was done in Rails 2, and caused so many problems that Bundler was created.
If that doesn't work, contact that banker guy on GitHub and ask him what the deps are or work out the dependencies yourself.
Good luck!
Depending on the version of rails this app uses you may have to execute the following :
script/server