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] Ability to pass extra luarocks installation args #439

Closed
SuperBo opened this issue Jul 1, 2024 · 12 comments · Fixed by #442
Closed

[Feature] Ability to pass extra luarocks installation args #439

SuperBo opened this issue Jul 1, 2024 · 12 comments · Fixed by #442
Assignees
Labels
enhancement New feature or request

Comments

@SuperBo
Copy link

SuperBo commented Jul 1, 2024

Hi, when installing https://github.com/SuperBo/fugit2.nvim with Rocks :Rocks install fugit2.nvim. I met these errors.

Error: Could not find library file for GIT2
  No file /git2/lib/libgit2.dylib in /usr/local/lib
  No file /git2/lib/libgit2.dylib in /usr/local
  No file libgit2.tbd in /usr/local/lib
  No file libgit2.tbd in /usr/local
  No file libgit2.a in /usr/local/lib
  No file libgit2.a in /usr/local
  No file libgit2.dylib in /usr/local/lib
  No file libgit2.dylib in /usr/local
  No file matching libgit2.so.* in /usr/local/lib
  No file matching libgit2.so.* in /usr/local
  No file /git2/lib/libgit2.dylib in /usr/lib
  No file /git2/lib/libgit2.dylib in /usr
  No file libgit2.tbd in /usr/lib
  No file libgit2.tbd in /usr
  No file libgit2.a in /usr/lib
  No file libgit2.a in /usr
  No file libgit2.dylib in /usr/lib
  No file libgit2.dylib in /usr
  No file matching libgit2.so.* in /usr/lib
  No file matching libgit2.so.* in /usr
  No file /git2/lib/libgit2.dylib in /lib
  No file /git2/lib/libgit2.dylib in /
  No file libgit2.tbd in /lib
  No file libgit2.tbd in /
  No file libgit2.a in /lib
  No file libgit2.a in /
  No file libgit2.dylib in /lib
  No file libgit2.dylib in /
  No file matching libgit2.so.* in /lib
  No file matching libgit2.so.* in /
  No file /git2/lib/libgit2.dylib in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
  No file /git2/lib/libgit2.dylib in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr
  No file libgit2.tbd in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
  No file libgit2.tbd in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr
  No file libgit2.a in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
  No file libgit2.a in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr
  No file libgit2.dylib in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
  No file libgit2.dylib in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr
  No file matching libgit2.so.* in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib
  No file matching libgit2.so.* in /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr
  No file /git2/lib/libgit2.dylib in /usr/local/opt/lib
  No file /git2/lib/libgit2.dylib in /usr/local/opt
  No file libgit2.tbd in /usr/local/opt/lib
  No file libgit2.tbd in /usr/local/opt
  No file libgit2.a in /usr/local/opt/lib
  No file libgit2.a in /usr/local/opt
  No file libgit2.dylib in /usr/local/opt/lib
  No file libgit2.dylib in /usr/local/opt
  No file matching libgit2.so.* in /usr/local/opt/lib
  No file matching libgit2.so.* in /usr/local/opt
You may have to install GIT2 in your system and/or pass GIT2_DIR or GIT2_LIBDIR to the luarocks command.
Example: luarocks install fugit2.nvim GIT2_DIR=/usr/local

I want to install fugit2.nvim with custom GIT2_DIR or GIG2_LIBDIR. How can I achieve this with :Rocks command.

@mrcjkb
Copy link
Member

mrcjkb commented Jul 1, 2024

Hey 👋

I don't think we currently support that. But it should be possible to implement something for

[plugins."fugit2.nvim"]
version = "1.0.0"
install_args = [
  "GIT2_DIR=/some/path"
]

We would probably be faster to support it in rocks.toml only initially (so you'd have to enter it manually and then install it with :Rocks sync).
And then later we could find a nice way to pass the install_args to :Rocks install.

@vhyrro what are your thoughts on this?

@mrcjkb mrcjkb self-assigned this Jul 1, 2024
@mrcjkb mrcjkb added the enhancement New feature or request label Jul 1, 2024
@mrcjkb mrcjkb changed the title How to pass extra lua rock installation args [Feature] Ability to pass extra luarocks installation args Jul 1, 2024
@vhyrro
Copy link
Collaborator

vhyrro commented Jul 1, 2024

As an initial implementation install_args looks good to me.
This whole issue gave me an idea - I was wondering whether we should allow arbitrary key=value pairs in the invocation of :Rocks install. For instance, allowing :Rocks install something opt=true ft=markdown and feeding that directly into the toml.

@vhyrro
Copy link
Collaborator

vhyrro commented Jul 1, 2024

Actually, instead of doing this, should we instead support an [env] section in the toml, which would modify vim.env? Or does luarocks not consider environment variables when building?

@SuperBo
Copy link
Author

SuperBo commented Jul 1, 2024

@vhyrro, I think those ARGS must be provided via luarocks args and is not env variables.

So I will disable external dependencies in the plugin first while wating for the rocks.nvim supports for extra args.

Refs:

@mrcjkb
Copy link
Member

mrcjkb commented Jul 1, 2024

For instance, allowing :Rocks install something opt=true ft=markdown and feeding that directly into the toml.

We already do that1 😉

What could be tricky is coming up with a good API for args that are lists:

:Rocks install {rock} opt=true install_args=["GIT2_DIR=/some/path","foo","bar"]

or

:Rocks install {rock} opt=true install_args=[GIT2_DIR=/some/path,foo,bar]

or, assuming any args that rocks.nvim can't parse are install_args:

:Rocks install {rock} opt=true GIT2_DIR=/some/path

The last one is more concise, but also more brittle: If someone passes in ft=markdown, it would be added to the install_args as long as rocks-lazy.nvim doesn't register an arg parser.

should we instead support an [env] section in the toml, which would modify vim.env?

Luarocks won't pick up GIT2_DIR from an environment variable. It has to be passed as an arg to install.

Since this is more of an edge case, I think we don't need to prioritise passing install_args via :Rocks install initially.

Footnotes

  1. As long as the extensions know how to parse args that rocks.nvim doesn't know about.
    So far, only rocks.nvim and rocks-git.nvim know how to parse args.

@vhyrro
Copy link
Collaborator

vhyrro commented Jul 1, 2024

Oh wow, I didn't even know we did generic parsing of arguments like that.

If env variables don't cut it (why, luarocks, why?), then I'm all for install_args. I wouldn't worry about parsing them inline for the time being, it'll become very complicated very quick.

@SuperBo
Copy link
Author

SuperBo commented Jul 2, 2024

@mrcjkb, thank you for quick fix. When will you release a new version with this fix?

@mrcjkb
Copy link
Member

mrcjkb commented Jul 2, 2024

@mrcjkb, thank you for quick fix. When will you release a new version with this fix?

Just waiting for a review from one of the other maintainers 😄

@teto
Copy link
Member

teto commented Jul 2, 2024

rather than

[plugins."fugit2.nvim"]
version = "1.0.0"
install_args = [
  "GIT2_DIR=/some/path"
]

shouldn't we set those in the luarocks config instead so it becomes available to all plugins ? and by "we" I actually mean the user because it's platform specific. Via somethling like vim.g.rocks_nvim.luarocks_external_dependencies

@vhyrro
Copy link
Collaborator

vhyrro commented Jul 2, 2024

rather than

[plugins."fugit2.nvim"]
version = "1.0.0"
install_args = [
  "GIT2_DIR=/some/path"
]

shouldn't we set those in the luarocks config instead so it becomes available to all plugins ? and by "we" I actually mean the user because it's platform specific. Via somethling like vim.g.rocks_nvim.luarocks_external_dependencies

Luarocks permits providing flags on a per-install basis via luarocks install, so it makes sense to permit per-rock configs :)

@teto
Copy link
Member

teto commented Jul 2, 2024

my point is that putting those per plugin, you might have to repeat the same instructions for each plugin to find git, libzip etc so it's best to set them globally by default and if a plugin wants to override it, it can

@mrcjkb
Copy link
Member

mrcjkb commented Jul 2, 2024

It would be neat if you could set them globally by default or via an environment variable.
But that's a luarocks issue. As long as luarocks doesn't support it, I don't feel comfortable hacking it into rocks.nvim.

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

Successfully merging a pull request may close this issue.

4 participants