Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EA build: Crashes when config/puma.rb starts with the line #!/usr/bin/env puma #3623

Closed
mohamedhafez opened this issue Jul 19, 2024 · 3 comments
Assignees
Labels
third-party-issue An issue which should be fixed upstream

Comments

@mohamedhafez
Copy link
Contributor

mohamedhafez commented Jul 19, 2024

My 'config/puma.rb' in my Rails project #!/usr/bin/env puma. If I remove that line everything works fine, but with it, when I try to run my rails server in RubyMine I get the following error and stack trace

/opt/homebrew/bin/bash -c "env 'RBENV_VERSION=truffleruby+graalvm-dev' /Users/mohamed/.rbenv/libexec/rbenv exec truffleruby /Users/mohamed/rubyprojects/substitutealert/bin/rails server -b 127.0.0.1 -p 3000 -e development"
=> Booting Puma
=> Rails 6.1.7.4 application starting in development 
=> Run `bin/rails server --help` for more startup options
[main] WARN io.netty.resolver.dns.DnsServerAddressStreamProviders - Can not find io.netty.resolver.dns.macos.MacOSDnsServerAddressStreamProvider in the classpath, fallback to system defaults. This may result in incorrect DNS resolutions on MacOS. Check whether you have a dependency on 'io.netty:netty-resolver-dns-native-macos'
Exiting
/Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/puma-6.4.2/lib/puma/dsl.rb:130:in `_load_from': config/puma.rb:1: no Ruby script found in input (SyntaxError)
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/puma-6.4.2/lib/puma/configuration.rb:239:in `block in load'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/puma-6.4.2/lib/puma/configuration.rb:239:in `each'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/puma-6.4.2/lib/puma/configuration.rb:239:in `load'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/puma-6.4.2/lib/puma/launcher.rb:54:in `initialize'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/puma-6.4.2/lib/rack/handler/puma.rb:72:in `run'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/rack-2.2.9/lib/rack/server.rb:327:in `start'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/railties-6.1.7.4/lib/rails/commands/server/server_command.rb:39:in `start'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/railties-6.1.7.4/lib/rails/commands/server/server_command.rb:144:in `block in perform'
	from <internal:core> core/kernel.rb:520:in `tap'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/railties-6.1.7.4/lib/rails/commands/server/server_command.rb:135:in `perform'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/thor-1.3.1/lib/thor/command.rb:28:in `run'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/thor-1.3.1/lib/thor/invocation.rb:127:in `invoke_command'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/thor-1.3.1/lib/thor.rb:527:in `dispatch'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/railties-6.1.7.4/lib/rails/command/base.rb:69:in `perform'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/railties-6.1.7.4/lib/rails/command.rb:48:in `invoke'
	from /Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/gems/gems/railties-6.1.7.4/lib/rails/commands.rb:18:in `<top (required)>'
	from <internal:core> core/kernel.rb:229:in `gem_original_require'
	from <internal:/Users/mohamed/.rbenv/versions/truffleruby+graalvm-dev/lib/mri/rubygems/core_ext/kernel_require.rb>:38:in `require'
	from /Users/mohamed/rubyprojects/substitutealert/bin/rails:4:in `<main>'

Process finished with exit code 1

my RUBY_DESCRIPTION is: "truffleruby 24.2.0-dev-7484fe29, like ruby 3.2.4, Oracle GraalVM JVM [arm64-darwin20]"

This works just fine on the latest stable release of TruffleRuby. I don't actually think that line is necessary so its not a big deal, but if figure a lot of people who copied the same template years ago might have the same issue, so figured I'd report it here

@andrykonchin
Copy link
Member

Thank you for the report, we'll look into it.

@andrykonchin
Copy link
Member

andrykonchin commented Jul 22, 2024

It seems the issue is how #eval (or #instance_eval in this case) handles #!/usr/bin/env puma.

Example of such file:

#!/usr/bin/env puma

puts 'Hello'

In CRuby the #eval method seems ignores it, but running such a file in shell with explicit ruby command (e.g. ruby config/puma.rb) will raise the mentioned above "no Ruby script found in input" SyntaxError. In TruffleRuby the exception will be raised in both cases.

Reported an issue in ruby/prism ruby/prism#2947.

@andrykonchin andrykonchin added the third-party-issue An issue which should be fixed upstream label Jul 22, 2024
@andrykonchin
Copy link
Member

The issue was fixed in Prism. Will be applied after the next updating Prism in TruffleRuby.

@andrykonchin andrykonchin self-assigned this Jul 25, 2024
headius pushed a commit to headius/spec that referenced this issue Nov 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
third-party-issue An issue which should be fixed upstream
Projects
None yet
Development

No branches or pull requests

2 participants