truffleruby icon indicating copy to clipboard operation
truffleruby copied to clipboard

`mx sforceimports` error ignored by `jt build`

Open nirvdrum opened this issue 4 years ago • 2 comments

I've had difficulty getting a TruffleRuby build working today and tried rebuilding a few times. I had tried a few branches and kept getting an the following error:

❯ jt ruby -e 'p :hi'
Using TruffleRuby with Graal: mxbuild/truffleruby-jvm-ce
$ /Users/nirvdrum/dev/workspaces/truffleruby-ws/truffleruby/mxbuild/truffleruby-jvm-ce/languages/ruby/bin/ruby \
  --experimental-options \
  --core-load-path=/Users/nirvdrum/dev/workspaces/truffleruby-ws/truffleruby/src/main/ruby/truffleruby \
  -e \
  'p :hi'
<internal:core> core/truffle/regexp_operations.rb:33:in `search_region': Unknown identifier: isBacktracking (NameError)
	from <internal:core> core/truffle/regexp_operations.rb:50:in `match_from'
	from <internal:core> core/regexp.rb:194:in `==='
	from <internal:core> core/symbol.rb:61:in `inspect'
	from <internal:core> core/post.rb:94:in `block in p'
	from <internal:core> core/post.rb:94:in `each'
	from <internal:core> core/post.rb:94:in `p'
	from -e:1:in `<main>'

Eventually I realized that upon each build I was being prompted to update the Graal imports. So, I decided to try jt mx sforceimports directly and that ended up failing because I had a local Graal change that I forgot about:

❯ jt mx sforceimports
$ /Users/nirvdrum/dev/workspaces/truffleruby-ws/mx/mx --java-home /Users/nirvdrum/.mx/jdks/labsjdk-ce-11-jvmci-21.3-b01/Contents/Home sforceimports
error: Your local changes to the following files would be overwritten by checkout:
	regex/src/com.oracle.truffle.regex/src/com/oracle/truffle/regex/tregex/parser/flavors/RubyFlavorProcessor.java
Please commit your changes or stash them before you switch branches.
Aborting
WARNING: Failed to update regex (in /Users/nirvdrum/dev/workspaces/truffleruby-ws/graal) to version bc35c63a6db0aa8faf5471b74f9771c7be8f7a9b! Leaving it at d9131d2778d6fb11a9b0270f00b4c8738a92c518.

Maybe the issue is really with mx sforceimports as that doesn't exit with an error code:

truffleruby on  master [$!?⇡] via 💎 v2.7.3 on ☁️  [email protected]
❯ echo $status
0

This ended up being self-inflicted, but it would have been nice if jt build noticed that mx sforceimports failed and provided an error.

nirvdrum avatar Jul 29 '21 19:07 nirvdrum

Right, I agree mx sforceimports should fail in that case (exit status != 0), because it fails to do what we ask it to. Could you make a PR to mx to fix that?

There should be "error: Your local changes ..." in the output of jt build too BTW, since that just runs mx sforceimports if you tell it to.

eregon avatar Jul 30 '21 11:07 eregon

Another possibility I've thought about is to scheckimports again after sforceimports, but that's not great for cases where it's impossible to match all imports (e.g., when building both JS and Ruby and they have different graal imports). So fixing sforceimports seems much better.

eregon avatar Jul 30 '21 11:07 eregon

Does #2935 fix this?

nirvdrum avatar Mar 13 '23 15:03 nirvdrum

Yes, good catch, https://github.com/graalvm/mx/commit/ec2696fabfd92f200a3845c7f7f04c5c805528e8 fixes this (@horakivo ran into this issue today). I'll close this already so I don't forget, but we'll update the minimum mx version in truffleruby so to ensure mx is recent enough to have that fix.

eregon avatar Mar 13 '23 17:03 eregon