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

Feature Request: Automatically reshim after a mix escript.install command successfully finishes #103

Open
axelson opened this issue May 26, 2021 · 8 comments

Comments

@axelson
Copy link

axelson commented May 26, 2021

The current Livebook instructions say that if you're using asdf you need to run asdf reshim elixir after installing livebook as an escript:

Running Livebook using Escript makes for a very convenient option
for local usage and provides easy configuration via CLI options.

mix escript.install hex livebook

# Start the Livebook server
livebook server

# See all the configuration options
livebook server --help

After you install the escript, make sure you add the directory where
Elixir keeps escripts to your $PATH.
If you installed Elixir with asdf, you'll need to run asdf reshim elixir
once the escript is built.

Source:
https://github.com/elixir-nx/livebook/blob/26226a42e0544fe3870c29bc68d752e7d6d3e63c/README.md#escript

Is it possible for asdf-elixir to detect that asdf escript.install has successfully installed an escript and then automatically reshim? If not that's fine, just figured I'd ask to remove a potential stumbling block. Escripts are always executable binaries so reshiming makes sense (to me). We'd probably have to do it when uninstalling an escript as well.

@hubertlepicki
Copy link

Yeah I have stumbled upon the same thing as well. I installed livebook and the command wasn't in the $PATH until I ran reshim command.

@kamidev
Copy link

kamidev commented Oct 29, 2021

Yes, this has bit me too. Seems like a general problem asdf has with additional binaries. For instance, something very similar happens with node.js and npm: https://asdf-vm.com/manage/core.html#reshim.

This project clearly says in the README that you should reshim after building escripts. But it's still easy to miss until you learn the hard way. Rebuilding the escripts path seems easy enough, but it's not obvious to me how to trigger that. Any idea?

@hubertlepicki
Copy link

I'm not entirely sure how the reshim thing works, and if it takes into consideration just the existence of the binaries or also is needed when binary file changes, but it seems like the easiest thing to do would be to

  • list the binaries before running the command, possibly with their checksums if that's important
  • list the binaries after running the command, again possibly with checksums
  • see if the paths changed

What we probably don't want to do is to run it after each and every command out there, but only limit it to things that can affect the binaries, so in this case "mix" command that's a binary itself in the bin/ path of Elixir installation...

I don't know, this is not trivial.

@Stratus3D
Copy link
Member

@axelson @kamidev @hubertlepicki, I don't have time to work on this myself right now, but a PR would be welcome. I think the asdf-nodejs plugin does something along these lines with the custom npm shim - https://github.com/asdf-vm/asdf-nodejs/blob/master/shims/npm That npm shim may not be working at the moment, but it should be possible to do something similar and get it working for mix deps.get.

@kamidev
Copy link

kamidev commented Oct 30, 2021

I'll take a look at this. Perhaps a separate shim for escript would be enough? Or is there a reason we need to check mix deps.get, too?

@axelson
Copy link
Author

axelson commented Oct 30, 2021

I don't think we need to reshim after a mix deps.get because that won't add any global binaries. I think we'd only need to automatically reshim after mix escript.install and mix escript.uninstall.

@kamidev
Copy link

kamidev commented Oct 30, 2021

That's what I was thinking, too. I am playing around trying to get a forked project with an 'escript' shim (based on the npm example above) to run. I'll keep you updated if I make any progress.

@axelson
Copy link
Author

axelson commented Oct 30, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants