sonic-pi-tool icon indicating copy to clipboard operation
sonic-pi-tool copied to clipboard

Use Ruby included with Sonic Pi for start-server

Open yaychris opened this issue 7 years ago • 2 comments

Sonic Pi's server/bin/sonic-pi-server.rb has a shebang line for #!/usr/bin/env ruby. When running sonic-pi-tool start-server from the command line, it uses whatever ruby it finds in your PATH. If it's not 2.3 (the version bundled with Sonic Pi), it fails:

$ ruby --version
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-darwin16]

$ sonic-pi-tool start-server
/Users/chris/Applications/Sonic Pi.app/app/server/vendor/fast_osc-0.0.11/lib/fast_osc.rb:22:in `require_relative': cannot load such file -- /Users/chris/Applications/Sonic Pi.app/app/server/rb-native/osx/2.4.0/fast_osc (LoadError)
        from /Users/chris/Applications/Sonic Pi.app/app/server/vendor/fast_osc-0.0.11/lib/fast_osc.rb:22:in `rescue in <top (required)>'
[omitted]

It's looking for files in Sonic Pi.app/app/server/rb-native/osx/2.4.0 instead of Sonic Pi.app/app/server/rb-native/osx/2.3.0.

It would be super cool if the start-server command, after determining the correct path to the Sonic Pi installation, started the server using the Ruby included in the package (Sonic Pi.app/app/server/native/osx/ruby/bin).

Again, as mentioned in #17, I'd gladly implement this but I don't have the Rust knowledge to make it happen :(

yaychris avatar May 12 '17 04:05 yaychris

This is great, thanks Chris.

Would you like to send over a PR with as far as you've got and then we can see if we can resolve the Rust tricky-ness. You've done work here, so it'd be nice for you to get a contribution in the repo :)

Probably only need to prepend the sandboxed ruby path to the command and ignore the shebang?

lpil avatar May 12 '17 08:05 lpil

Great project, thank you for your work! Leaving this note in case anyone runs into a similar issue as I. I experienced something similar to what is described in this Issue and I resolved it by upgrading my Ruby system install to 2.5.x given how the Sonic Pi dependencies seem to resolve (it appears 2.4.x will work too). There wasn't support for my default macOS Mojave Ruby install of 2.3.7 or the most recent stable Ruby version (2.6.3 as of the time of this writing).

fwinokur avatar Feb 23 '19 20:02 fwinokur