部署到 Heroku 时出现 Rails rake 问题

时间:2021-01-02 19:01:24

标签: ruby-on-rails heroku rake bundler gemfile

解决方案:我使用 Bundler 版本 2.2.4 运行 ruby​​ 2.6.6p146。根据@thiebo 的建议,我降级到 Bundler 2.1.2 并且成功了!步骤:

  1. $ gem 卸载捆绑器
  2. [然后删除 Gemfile.lock]
  3. $ gem install bundler --version '2.1.2'

我尝试了这些选项,但没有任何效果:heroku push error: "Could not detect rake tasks"

我确实可以对我的应用程序运行 bundle exec rake -P

我尝试拯救 Rakefile,并在我的 Gemfile 中将 rspec 投入生产:Heroku could not detect rake tasks (LoadError: cannot load such file -- rspec/core/rake_task)

我在 gemfile 中添加了 'rake'。

尝试添加 gem 'rack-timeout':Heroku 'Could not detect rake tasks'

我也跟着这个线程无济于事:https://github.com/rubygems/bundler/issues/3640

错误如下:

const recordAudio = () =>
    new Promise(async resolve => {
        const stream = await navigator.mediaDevices.getUserMedia({ audio: true });
        const mediaRecorder = new MediaRecorder(stream);
        const audioChunks = [];

        mediaRecorder.addEventListener("dataavailable", event => {
            audioChunks.push(event.data);
        });

        const start = () => mediaRecorder.start();

        const stop = () =>
            new Promise(resolve => {
                mediaRecorder.addEventListener("stop", () => {
                    const audioBlob = new Blob(audioChunks);
                    const audioUrl = URL.createObjectURL(audioBlob);
                    const audio = new Audio(audioUrl);
                    const play = () => audio.play();
                    resolve({ audioBlob, audioUrl, play });
                });

                mediaRecorder.stop();
            });

        resolve({ start, stop });
    });

const sleep = time => new Promise(resolve => setTimeout(resolve, time));

const handleAction = async () => {
    const recorder = await recordAudio();
    const actionButton = document.getElementById('action');
    actionButton.disabled = true;
    recorder.start();
    await sleep(3000);
    const audio = await recorder.stop();
    //audio.play();
    console.log(audio);
    await sleep(3000);
    console.log("Finished");
    actionButton.disabled = false;
}

非常感谢,如果有人知道。

2 个答案:

答案 0 :(得分:2)

简答

使用 Heroku 支持的 bundler 版本

  gem uninstall bundler
  gem install bundler --version '2.1.2'

  rm Gemfile.lock
  bundle install

  git add Gemfile.lock
  git commit -m "downgrade bundler to appease the Heroku gods"
  git push heroku

这个问题好像以前也发生过:https://github.com/rubygems/bundler/issues/7486

答案 1 :(得分:0)

我刚刚遇到了这个问题和 official documentation worked

<块引用>

捆绑器 2.2.3+

在本地使用 Bundler 2.2.3 生成的应用程序的 Gemfile.lock 可能无法在 Heroku 上运行,除非 Linux 平台被明确“锁定”:

$ bundle lock --add-platform ruby
$ bundle lock --add-platform x86_64-linux
$ bundle install
$ git add . ; git commit -m "Bundler fix"
相关问题