khvzak / lua-ryaml

A fast Lua YAML library written in Rust using serde
MIT License
10 stars 0 forks source link

Document how to install on Linux via sudo #2

Open drauschenbach opened 8 months ago

drauschenbach commented 8 months ago

I can install this module on my Mac with sudo luarocks install lua-ryaml. However on Debian 12 Linux the Rust environment does not get set when sudo is invoked. this thread mentions something similar.

$ sudo luarocks install lua-ryaml
Installing https://luarocks.org/lua-ryaml-0.1.0-1.src.rock

lua-ryaml 0.1.0-1 depends on lua >= 5.1 (5.1-1 provided by VM)
lua-ryaml 0.1.0-1 depends on luarocks-build-rust-mlua (0.1.2-1 installed)

Error: Build error: 'cargo' is not installed.
This rock is written in Rust: make sure you have a Rust
development environment installed and try again.
$ sudo su -
$ cargo --version
cargo 1.75.0 (1d8b05cdd 2023-11-20)

In my own mlua based projects I'd like to document for the end user how to install the LuaRock.

khvzak commented 8 months ago

How is rust/cargo installed? Can you run which cargo from root env?

drauschenbach commented 8 months ago

How is rust/cargo installed? Can you run which cargo from root env?

Rust was installed with curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh. Yes the root env can find cargo, which is what this is demonstrating:

$ sudo su -
$ cargo --version
cargo 1.75.0 (1d8b05cdd 2023-11-20)

It is sudo that seems intentionally unsupported by the Rust tooling.

khvzak commented 8 months ago

Yes the root env can find cargo, which is what this is demonstrating:

But could you run which cargo on root env, to see exact path? And could you try sudo -i cargo to see if it can be found.

It is sudo that seems intentionally unsupported by the Rust tooling.

It's not about rust tooling. This code checks for cargo presence. So seems luarocks.fs.is_tool_available cannot find it.

drauschenbach commented 8 months ago

Like this? I did the rustup install separately for both my user and the root user.

$ sudo su -
root@bitscope-0:~# which cargo
/root/.cargo/bin/cargo
drauschenbach commented 8 months ago

Maybe this has to do with sudo not running the shell .profile, which contains:

mesg n 2> /dev/null || true
. "$HOME/.cargo/env"