0

I see this dreaded message;

remote:  !
remote:  !     Could not detect rake tasks
remote:  !     ensure you can run `$ bundle exec rake -P` against your app
remote:  !     and using the production group of your Gemfile.
remote:  !     /tmp/build_c4484669/bin/rake:8:in `require': cannot load such file -- rake (LoadError)
remote:  !     from /tmp/build_c4484669/bin/rake:8:in `<main>'
remote:  !
remote: /tmp/codon/tmp/buildpacks/50d5eddf222a9b7326028041d4e6509f915ccf2c/lib/language_pack/helpers/rake_runner.rb:106:in `load_rake_tasks!': Could not detect rake tasks (LanguagePack::Helpers::RakeRunner::CannotLoadRakefileError)
remote: ensure you can run `$ bundle exec rake -P` against your app
remote: and using the production group of your Gemfile.
remote: /tmp/build_c4484669/bin/rake:8:in `require': cannot load such file -- rake (LoadError)

Yet I've run bundle exec rake -P and it works fine. How exactly does one ensure they are running that command "using the production group of your Gemfile"?

Notes

Here are the help docs - can't see any option for using production group in Gemfile:

rake --help
rake [-f rakefile] {options} targets...

Options are ...
        --backtrace=[OUT]            Enable full backtrace.  OUT can be stderr (default) or stdout.
        --comments                   Show commented tasks only
        --job-stats [LEVEL]          Display job statistics. LEVEL=history displays a complete job list
        --rules                      Trace the rules resolution.
        --suppress-backtrace PATTERN Suppress backtrace lines matching regexp PATTERN. Ignored if --trace is on.
    -A, --all                        Show all tasks, even uncommented ones (in combination with -T or -D)
    -B, --build-all                  Build all prerequisites, including those which are up-to-date.
    -D, --describe [PATTERN]         Describe the tasks (matching optional PATTERN), then exit.
    -e, --execute CODE               Execute some Ruby code and exit.
    -E, --execute-continue CODE      Execute some Ruby code, then continue with normal task processing.
    -f, --rakefile [FILENAME]        Use FILENAME as the rakefile to search for.
    -G, --no-system, --nosystem      Use standard project Rakefile search paths, ignore system wide rakefiles.
    -g, --system                     Using system wide (global) rakefiles (usually '~/.rake/*.rake').
    -I, --libdir LIBDIR              Include LIBDIR in the search path for required modules.
    -j, --jobs [NUMBER]              Specifies the maximum number of tasks to execute in parallel. (default is number of CPU cores + 4)
    -m, --multitask                  Treat all tasks as multitasks.
    -n, --dry-run                    Do a dry run without executing actions.
    -N, --no-search, --nosearch      Do not search parent directories for the Rakefile.
    -P, --prereqs                    Display the tasks and dependencies, then exit.
    -p, --execute-print CODE         Execute some Ruby code, print the result, then exit.
    -q, --quiet                      Do not log messages to standard output.
    -r, --require MODULE             Require MODULE before executing rakefile.
    -R, --rakelibdir RAKELIBDIR,     Auto-import any .rake files in RAKELIBDIR. (default is 'rakelib')
        --rakelib
    -s, --silent                     Like --quiet, but also suppresses the 'in directory' announcement.
    -t, --trace=[OUT]                Turn on invoke/execute tracing, enable full backtrace. OUT can be stderr (default) or stdout.
    -T, --tasks [PATTERN]            Display the tasks (matching optional PATTERN) with descriptions, then exit. -AT combination displays all of tasks contained no description.
    -v, --verbose                    Log message to standard output.
    -V, --version                    Display the program version.
    -W, --where [PATTERN]            Describe the tasks (matching optional PATTERN), then exit.
    -X, --no-deprecation-warnings    Disable the deprecation warnings.
    -h, -H, --help                   Display this help message.
stevec
  • 41,291
  • 27
  • 223
  • 311
  • To use the production group of the `Gemfile`, run `RAILS_ENV=production bundle exec rake -P`. Which version of bundler are you using? – Arun Kumar Mohan Apr 27 '21 at 06:16
  • @ArunKumarMohan great question. Basically I can't push to heroku, they are fussy about which bundler versions they accept: https://devcenter.heroku.com/articles/bundler-version So i've been uninstalling/reinstalling different versions trying to find one that works. Mostly 2.1.4 or 2.2.16 – stevec Apr 27 '21 at 06:20
  • Which version is your `Gemfile.lock` bundled with? `tail Gemfile.lock | grep 'BUNDLED' -A 1`. – Arun Kumar Mohan Apr 27 '21 at 06:25
  • @ArunKumarMohan I delete the Gemfile.lock every time, so it updates to whatever bundler version I try. Right now it's `2.1.4` but if I uninstall bundler 2.1.4 and install another version, delete Gemfile.lock, and bundle again, that will update to the new bundler – stevec Apr 27 '21 at 06:27
  • @ArunKumarMohan yep, on mac. Basically when I use 2.1.4, for whatever reason, the build process [gets stuck for 54 minutes and then fails](https://stackoverflow.com/q/67268563/5783745), which is hard to explain or diagnose – stevec Apr 27 '21 at 06:31
  • Do you get the same issue when running with bundler v2.1.4? – Arun Kumar Mohan Apr 27 '21 at 06:31
  • Weird. [Apps using Bundler v2.2.3 have issues with Heroku deployments](https://github.com/rubygems/rubygems/issues/4269) which could be fixed by running `bundle lock --add-platform x86_64-linux`. – Arun Kumar Mohan Apr 27 '21 at 06:32
  • @ArunKumarMohan I also got that same error on some bundler versions, and used that command to fix it. But it would eventually lead to the problem in the question – stevec Apr 27 '21 at 06:35

0 Answers0