jakeg / heroku-buildpack-bun

Heroku buildpack for Bun.js
MIT License
18 stars 21 forks source link

Rails app still can't deploy during assets:precompile #5

Closed joemsak closed 1 day ago

joemsak commented 1 month ago

Tried to upgrade to cssbundling-rails 1.3.3 or 1.4.0 which support bun, and deploy to heroku with this buildpack

(Same deal with jsbundling-rails 1.1.2 -> 1.2.2, 1.3.0 due to similar bun support added)

-----> https://github.com/jakeg/heroku-buildpack-bun app detected
#=#=#                                                                         bun was installed successfully to /tmp/build_b164eac6/.heroku/bin/bun 
Manually add the directory to ~/.bash_profile (or similar):
  export BUN_INSTALL="/tmp/build_b164eac6/.heroku" 
  export PATH=$BUN_INSTALL/bin:$PATH 
To get started, run: 
  bun --help 
Installing dependencies...
[0.04ms] ".env.production"
bun install v1.1.12 (43f0913c)
+ eslint@9.4.0
...
+ tailwindcss@2.2.19
579 packages installed [2.21s]
Blocked 1 postinstall. Run `bun pm untrusted` for details.
-----> Ruby app detected
-----> Installing bundler 2.5.6`
...
-----> Installing node-v20.9.0-linux-x64
-----> Installing yarn-v1.22.19
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       I, [2024-06-05T14:06:00.286037 #3047]  INFO -- ddtrace: [ddtrace] DATADOG CONFIGURATION - CORE - {"date":"2024-06-05T14:06:00Z","os_name":"x86_64-pc-linux","version":"1.23.0","lang":"ruby","lang_version":"3.3.2","env":"staging","service":"rake","dd_version":null,"debug":false,"tags":"env:staging","runtime_metrics_enabled":false,"vm":"ruby-3.3.2","health_metrics_enabled":false,"profiling_enabled":false}
       [dotenv] Loaded .env.production
       [dotenv] Loaded .env.staging
       [dotenv] Loaded .env.production
       rake aborted!
       cssbundling-rails: Command install failed, ensure bun is installed
       /tmp/build_b164eac6/vendor/bundle/ruby/3.3.0/gems/cssbundling-rails-1.4.0/lib/tasks/cssbundling/build.rake:6:in `block (2 levels) in <main>'
       /tmp/build_b164eac6/vendor/bundle/ruby/3.3.0/gems/ddtrace-1.23.0/lib/datadog/tracing/contrib/rake/instrumentation.rb:30:in `execute'
       Tasks: TOP => assets:precompile => css:build => css:install

The failing line in cssbundling-rails https://github.com/rails/cssbundling-rails/blob/e650c9ab135504cc2f8b8405c41cdebad5ede66f/lib/tasks/cssbundling/build.rake#L26

I downgraded back to 1.2.0 and removed the buildpack, and my deploys are building again.

Here is our buildpack list now (after removing bun; it had been listed before node's)

Screenshot 2024-06-05 at 08-17-50 · Settings Heroku

jakeg commented 3 weeks ago

@joemsak can you confirm if this is still a bug?

joemsak commented 3 weeks ago

Trying today, will let you know. Thanks!

joemsak commented 3 weeks ago

Hey, no, sorry, it still broke (with the only change being that I upgraded the 2 gems):

Building on the Heroku-22 stack
-----> Deleting 3 files matching .slugignore patterns.
-----> Using buildpacks:
       1. heroku/exec
       2. https://github.com/mojodna/heroku-buildpack-jemalloc.git
       3. heroku/metrics
       4. heroku/nodejs
       5. heroku/ruby
       6. https://github.com/jakeg/heroku-buildpack-bun
-----> Heroku Exec app detected
-----> jemalloc app detected
-----> Vendoring binaries
       Fetching https://github.com/mojodna/heroku-buildpack-jemalloc/releases/download/4.2.1/jemalloc-4.2.1-1.tar.gz
-----> Configuring build environment
-----> Building runtime environment
-----> HerokuRuntimeMetrics app detected
-----> Setting up .profile.d to automatically run metrics agent...
-----> Node.js app detected

-----> Creating runtime environment

       NPM_CONFIG_LOGLEVEL=error
       USE_YARN_CACHE=true
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true

-----> Installing binaries
       engines.node (package.json):   ^22
       engines.npm (package.json):    unspecified (use default)
       engines.yarn (package.json):   unspecified (use default)

       Resolving node version ^22...
       Downloading and installing node 22.4.1...
       Using default npm version: 10.8.1
       Resolving yarn version 1.22.x...
       Downloading and installing yarn (1.22.22)
       Installed yarn 1.22.22

-----> Restoring cache
       - yarn cache

-----> Installing dependencies
       Installing node modules (yarn.lock)
       yarn install v1.22.22
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       [3/4] Linking dependencies...
       warning " > esbuild-sass-plugin@3.3.1" has unmet peer dependency "sass-embedded@^1.71.1".
       warning " > tailwindcss@2.2.19" has unmet peer dependency "autoprefixer@^10.0.2".
       warning " > eslint-config-airbnb@19.0.4" has incorrect peer dependency "eslint@^7.32.0 || ^8.2.0".
       warning " > eslint-config-airbnb@19.0.4" has unmet peer dependency "eslint-plugin-react@^7.28.0".
       warning " > eslint-config-airbnb@19.0.4" has unmet peer dependency "eslint-plugin-react-hooks@^4.3.0".
       warning "eslint-config-airbnb > eslint-config-airbnb-base@15.0.0" has incorrect peer dependency "eslint@^7.32.0 || ^8.2.0".
       warning " > eslint-config-react-app@7.0.1" has incorrect peer dependency "eslint@^8.0.0".
       warning "eslint-config-react-app > @babel/eslint-parser@7.22.9" has incorrect peer dependency "eslint@^7.5.0 || ^8.0.0".
       warning "eslint-config-react-app > @typescript-eslint/eslint-plugin@5.62.0" has incorrect peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
       warning "eslint-config-react-app > @typescript-eslint/parser@5.62.0" has incorrect peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
       warning " > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-syntax-flow@^7.14.5".
       warning " > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-transform-react-jsx@^7.14.9".
       warning " > eslint-plugin-flowtype@8.0.3" has incorrect peer dependency "eslint@^8.1.0".
       warning "eslint-config-react-app > eslint-plugin-import@2.27.5" has incorrect peer dependency "eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8".
       warning "eslint-config-react-app > eslint-plugin-jest@25.7.0" has incorrect peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
       warning "eslint-config-react-app > eslint-plugin-jsx-a11y@6.7.1" has incorrect peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8".
       warning "eslint-config-react-app > eslint-plugin-react@7.32.2" has incorrect peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8".
       warning "eslint-config-react-app > eslint-plugin-react-hooks@4.6.0" has incorrect peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0".
       warning "eslint-config-react-app > eslint-plugin-testing-library@5.11.0" has incorrect peer dependency "eslint@^7.5.0 || ^8.0.0".
       warning "eslint-config-react-app > @typescript-eslint/eslint-plugin > @typescript-eslint/utils@5.62.0" has incorrect peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
       warning "eslint-config-react-app > @typescript-eslint/eslint-plugin > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
       warning "eslint-config-react-app > eslint-plugin-jest > @typescript-eslint/experimental-utils@5.62.0" has incorrect peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
       warning " > eslint-plugin-import@2.29.1" has incorrect peer dependency "eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8".
       warning " > eslint-plugin-jsx-a11y@6.9.0" has incorrect peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8".
       [4/4] Building fresh packages...
       Done in 19.34s.

-----> Build
       Running build (yarn)
       yarn run v1.22.22
       $ node esbuild.config.js
       Done in 1.00s.

-----> Pruning devDependencies
       yarn install v1.22.22
       [1/4] Resolving packages...
       [2/4] Fetching packages...
       [3/4] Linking dependencies...
       warning " > esbuild-sass-plugin@3.3.1" has unmet peer dependency "sass-embedded@^1.71.1".
       warning " > tailwindcss@2.2.19" has unmet peer dependency "autoprefixer@^10.0.2".
       warning " > eslint-config-airbnb@19.0.4" has incorrect peer dependency "eslint@^7.32.0 || ^8.2.0".
       warning " > eslint-config-airbnb@19.0.4" has unmet peer dependency "eslint-plugin-react@^7.28.0".
       warning " > eslint-config-airbnb@19.0.4" has unmet peer dependency "eslint-plugin-react-hooks@^4.3.0".
       warning "eslint-config-airbnb > eslint-config-airbnb-base@15.0.0" has incorrect peer dependency "eslint@^7.32.0 || ^8.2.0".
       warning " > eslint-config-react-app@7.0.1" has incorrect peer dependency "eslint@^8.0.0".
       warning "eslint-config-react-app > @babel/eslint-parser@7.22.9" has incorrect peer dependency "eslint@^7.5.0 || ^8.0.0".
       warning "eslint-config-react-app > @typescript-eslint/eslint-plugin@5.62.0" has incorrect peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
       warning "eslint-config-react-app > @typescript-eslint/parser@5.62.0" has incorrect peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
       warning " > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-syntax-flow@^7.14.5".
       warning " > eslint-plugin-flowtype@8.0.3" has unmet peer dependency "@babel/plugin-transform-react-jsx@^7.14.9".
       warning " > eslint-plugin-flowtype@8.0.3" has incorrect peer dependency "eslint@^8.1.0".
       warning "eslint-config-react-app > eslint-plugin-import@2.27.5" has incorrect peer dependency "eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8".
       warning "eslint-config-react-app > eslint-plugin-jest@25.7.0" has incorrect peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
       warning "eslint-config-react-app > eslint-plugin-jsx-a11y@6.7.1" has incorrect peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8".
       warning "eslint-config-react-app > eslint-plugin-react@7.32.2" has incorrect peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8".
       warning "eslint-config-react-app > eslint-plugin-react-hooks@4.6.0" has incorrect peer dependency "eslint@^3.0.0 || ^4.0.0 || ^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0-0".
       warning "eslint-config-react-app > eslint-plugin-testing-library@5.11.0" has incorrect peer dependency "eslint@^7.5.0 || ^8.0.0".
       warning "eslint-config-react-app > @typescript-eslint/eslint-plugin > @typescript-eslint/utils@5.62.0" has incorrect peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
       warning "eslint-config-react-app > @typescript-eslint/eslint-plugin > tsutils@3.21.0" has unmet peer dependency "typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta".
       warning "eslint-config-react-app > eslint-plugin-jest > @typescript-eslint/experimental-utils@5.62.0" has incorrect peer dependency "eslint@^6.0.0 || ^7.0.0 || ^8.0.0".
       warning " > eslint-plugin-import@2.29.1" has incorrect peer dependency "eslint@^2 || ^3 || ^4 || ^5 || ^6 || ^7.2.0 || ^8".
       warning " > eslint-plugin-jsx-a11y@6.9.0" has incorrect peer dependency "eslint@^3 || ^4 || ^5 || ^6 || ^7 || ^8".
       [4/4] Building fresh packages...
       warning Ignored scripts due to flag.
       Done in 2.70s.

-----> Caching build
       - yarn cache

-----> Build succeeded!
 !     Unmet dependencies don't fail yarn install but may cause runtime issues
       https://github.com/npm/npm/issues/7494
-----> Ruby app detected
-----> Installing bundler 2.5.6
-----> Removing BUNDLED WITH version in the Gemfile.lock
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-3.3.2
-----> Installing dependencies using bundler 2.5.6
       Running: BUNDLE_WITHOUT='development:test' BUNDLE_PATH=vendor/bundle BUNDLE_BIN=vendor/bundle/bin BUNDLE_DEPLOYMENT=1 bundle install -j4
       Fetching gem metadata from https://rubygems.org/........
       Fetching gem metadata from https://enterprise.contribsys.com/..
       Fetching cssbundling-rails 1.4.0
       Fetching jsbundling-rails 1.3.0
       Installing cssbundling-rails 1.4.0
       Installing jsbundling-rails 1.3.0
       Bundle complete! 109 Gemfile dependencies, 191 gems now installed.
       Gems in the groups 'development' and 'test' were not installed.
       Bundled gems are installed into `./vendor/bundle`
       1 installed gem you directly depend on is looking for funding.
         Run `bundle fund` for details
       Bundle completed (3.76s)
       Cleaning up the bundler cache.
       Removing bundler (2.5.6)
       Removing cssbundling-rails (1.2.0)
       Removing jsbundling-rails (1.1.2)
-----> Detecting rake tasks
-----> Preparing app for Rails asset pipeline
       Running: rake assets:precompile
       [2024-07-11T18:41:08 (process) #2682][INFO] appsignal: Starting AppSignal 3.10.0 (/tmp/build_66b704f7/bin/rake, Ruby 3.3.2, x86_64-linux)
       rake aborted!
       cssbundling-rails: Command install failed, ensure bun is installed
       /tmp/build_66b704f7/vendor/bundle/ruby/3.3.0/gems/cssbundling-rails-1.4.0/lib/tasks/cssbundling/build.rake:6:in `block (2 levels) in <main>'
       /tmp/build_66b704f7/vendor/bundle/ruby/3.3.0/gems/appsignal-3.10.0/lib/appsignal/integrations/rake.rb:15:in `block in execute'
       /tmp/build_66b704f7/vendor/bundle/ruby/3.3.0/gems/appsignal-3.10.0/lib/appsignal/helpers/instrumentation.rb:705:in `instrument'
       /tmp/build_66b704f7/vendor/bundle/ruby/3.3.0/gems/appsignal-3.10.0/lib/appsignal/integrations/rake.rb:14:in `execute'
       Tasks: TOP => assets:precompile => css:build => css:install
       (See full trace by running task with --trace)

 !
 !     Precompiling assets failed.
 !
 !     Push rejected, failed to compile Ruby app.
 !     Push failed

I see your README says to have a procfile with a bun command (we're deploying a rails application, we only need asset precompilation, not a deployed process) or a package.json script.

/* package.json */
{
  /* ... */
  "scripts": {
    "lint": "eslint --fix \"**/*.{js,jsx,ts,tsx}\" --fix-type problem",
    "build:css": "tailwindcss -i ./app/assets/stylesheets/application.tailwind.css -o ./app/assets/builds/tailwind.css",
    "doc": "rails rerdoc && servor doc/",
    "build": "node esbuild.config.js"
  }
}

Should we do something else here? We only need rails assets:precompile to work, nothing else. Am I totally missing something or misunderstanding something?

joemsak commented 3 weeks ago

(We're still using Yarn due to lack of support for Bun on Heroku)

joemsak commented 3 weeks ago

Deploys are working with the bundling gems set back to their older versions, and while the buildpack is still installed on our heroku application.

jakeg commented 1 day ago

(We're still using Yarn due to lack of support for Bun on Heroku)

This buildpack gives that (unofficial) support.

It's possible that with this buildpack you no longer need yarn/npm/node at all, as bun is designed as a drop in replacement for node.

I'm afraid I'm not sure how to help with your problem though. I'm going to close this issue for now, but feel free to re-open it if you have anything else which I might be able to help with.

joemsak commented 1 day ago

Okay but as I said, I tried this build pack again after you made some updates, and we still did not get bun support on heroku.