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

fix: change the link target to $HOME/.local/bin/fvm in install.sh for linux #700

Open
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

Nidal-Bakir
Copy link

@Nidal-Bakir Nidal-Bakir commented Mar 22, 2024

This will fix: #699

Copy link

vercel bot commented Mar 22, 2024

@Nidal-Bakir is attempting to deploy a commit to the FlutterTools Team on Vercel.

A member of the Team first needs to authorize it.

@Nidal-Bakir Nidal-Bakir changed the title fix: update the link target to $HOME/.local/bin/fvm fix: change the link target to $HOME/.local/bin/fvm in install.sh on linux Mar 22, 2024
@Nidal-Bakir Nidal-Bakir changed the title fix: change the link target to $HOME/.local/bin/fvm in install.sh on linux fix: change the link target to $HOME/.local/bin/fvm in install.sh for linux Mar 22, 2024
Copy link

vercel bot commented Mar 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fvm ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 31, 2024 1:41pm

@SSebigo
Copy link

SSebigo commented May 5, 2024

Is it good ? This is the only problem I have with FVM right now.

@Nidal-Bakir
Copy link
Author

Nidal-Bakir commented May 6, 2024

@SSebigo
Yes, you can use this updated script to install FVM on Linux.
This will probably not get merged now, so you can copy and paste the updated script to your machine, make it executable, and run it.

@leoafarias
Copy link
Owner

@Nidal-Bakir Sorry for the delay on this, but can we maybe move the directory to ~/.fvm/bin/fvm instead of local, and make both mac and linux consistent?

@vicenterusso
Copy link

vicenterusso commented May 14, 2024

That script did work for me, fresh fedora40 install

ln: failed to create symbolic link '/home/vicente/.local/bin/fvm': No such file or directory
error: Failed to create symlink.

There is no .local/bin/ yet. should the script handle this, maybe?

Edit: the script auto assumes that $HOME/.local/bin is already in PATH, which might not be true in a fresh linux install

After manually creating local/bin folder and adding it to the PATH, the script worked

@toddtail
Copy link

@SSebigo Yes, you can use this updated script to install FVM on Linux. This will probably not get merged now, so you can copy and paste the updated script to your machine, make it executable, and run it.

The Script worked for me but still got 2 things needs to be done manually:

  1. create bin folder in ~/.local
  2. add export PATH="$PATH:$HOME/.local/bin/" to .bashrc file

genitalico added a commit to genitalico/fvm that referenced this pull request May 23, 2024
@Nidal-Bakir
Copy link
Author

@leoafarias

can we maybe move the directory to ~/.fvm/bin/fvm instead of local, and make both mac and linux consistent?

I cannot speak for the Mac because I do not have a Mac, and I do not know if Mac has a ./local/bin folder or if this folder is a standard thing in the Mac world. The ./local/bin is a conventional thing in the Linux world, and it is fair to assume that the developer who is bashing a script of the internet already has ./local/bin in his PATH variable.

Nonetheless, we can add some extra comments to note that the ./local/bin needs to be in the PATH variable, and you need to create such a folder if none exists.

@vicenterusso
Copy link

it is fair to assume that the developer who is bashing a script of the internet already has ./local/bin in his PATH variable.

Lets agree to disagree. You are correct. Most users should already have ./local/bin in his PATH variable. In my specific case, FVM was my first install after a fresh fedora install. I quickly fixed adding to the PATH and creating the ./local/bin folder.

But it shouldn't hurt having these small checks inside the script, makes it more reliable.

@Nidal-Bakir
Copy link
Author

Nidal-Bakir commented May 24, 2024

We can make the script create the ./local/bin folder mkdir -p $HOME/local/bin, but how can we add the PATH="$PATH:$HOME/.local/bin/ to .bashrc or .zshrc ... ETC. I'm not aware of a solution for that :/

@vicenterusso
Copy link

We can make the script create the ./local/bin folder mkdir -p $HOME/local/bin, but how can we add the PATH="$PATH:$HOME/.local/bin/ to .bashrc or .zshrc ... ETC. I'm not aware of a solution for that :/

That's trivial to add to PATH but personally I would just echo the instructions to the user add manually

@Nidal-Bakir
Copy link
Author

That's trivial to add to PATH but personally I would just echo the instructions to the user add manually

No, it's not trivial!

  • We can not use echo in this situation we do not know where the .bashrc/.zshrc.... files are!
  • Each time the user runs the script, the script will echo the instructions to the user .bashrc/.zshrc assuming we know the path of these files.

@Nidal-Bakir
Copy link
Author

So as for now, it turns out that some distros do not follow the XDG Base Directory Specification

User-specific executable files may be stored in $HOME/.local/bin. Distributions should ensure this directory shows up in the UNIX $PATH environment variable, at an appropriate place.

We need to do the following:

  1. Create the $HOME/.local/bin folder if it does not exist. We can easily do that using mkdir -p $HOME/.local/bin.
  2. Instruct the user to add $HOME/.local/bin/ to their PATH variable if it does not already exist.

@vicenterusso
Copy link

That's trivial to add to PATH but personally I would just echo the instructions to the user add manually

No, it's not trivial!

  • We can not use echo in this situation we do not know where the .bashrc/.zshrc.... files are!
  • Each time the user runs the script, the script will echo the instructions to the user .bashrc/.zshrc assuming we know the path of these files.

Jesus, man. when I say "echo" I mean display it to terminal to the user add it manually. But yes, its trivial to automatically add to correct shell file and still check if ts already set.

@Nidal-Bakir
Copy link
Author

Jesus, man. when I say "echo" I mean display it to terminal to the user add it manually. But yes, its trivial to automatically add to correct shell file and still check if ts already set.

Apologies for my mistake. I misinterpreted your comment. If you are confident about it, then please guide me in the right way.

@Nidal-Bakir
Copy link
Author

Nidal-Bakir commented May 24, 2024

So we have two options I think:

  1. Instruct the user to add $HOME/.local/bin/ to their PATH variable if it does not already exist using echo as an output of running the script. And I would add this to the website also just to be more clear for all the users
  2. if @vicenterusso has a script to add this to the user PATH var

@leoafarias
Copy link
Owner

@Nidal-Bakir When looking at similar .sh scripts to install, I found the use of .packagename over .local. For example, if you look at the install.sh for Bun on https://bun.sh, which you can find here: https://bun.sh/install, it seems the same behavior is for Mac and Linux and does use local.

Can you take a brief look at this, as it would be more straightforward to just set this?

@leoafarias
Copy link
Owner

@Nidal-Bakir, can you confirm my message above with the example from Bun? It seems they are not using local. I would prefer this approach if it works without manual intervention.

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

Successfully merging this pull request may close these issues.

[BUG] The install.sh script uses /usr/local/bin/fvm as a link target which requires sudo privileges
5 participants