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

fyne get requires root access #21

Open
2 tasks done
paboum opened this issue Nov 24, 2022 · 17 comments
Open
2 tasks done

fyne get requires root access #21

paboum opened this issue Nov 24, 2022 · 17 comments

Comments

@paboum
Copy link

paboum commented Nov 24, 2022

Checklist

  • I have searched the issue tracker for open issues that relate to the same problem, before opening a new one.
  • This issue only relates to a single bug. I will open new issues for any other problems.

Describe the bug

The fyne get command assumes /usr/local/bin as installation target (hardcoded) and makes no use of GOPATH env var.

$ fyne get fyne.io/apps
2022/11/24 05:08:10 Fyne error:  Failed to create dirrectory
2022/11/24 05:08:10   Cause: mkdir /usr/local/share: permission denied
2022/11/24 05:08:10   At: /usr/go/pkg/mod/fyne.io/fyne/[email protected]/cmd/fyne/internal/util/file.go:36
failed to copy application binary file: open /usr/local/bin/apps: permission denied

How to reproduce

$ fyne get fyne.io/apps

Screenshots

No response

Example code

	if _, err := os.Stat(filepath.Join("/", "usr", "local")); os.IsNotExist(err) {
		prefixDir = util.EnsureSubDir(util.EnsureSubDir(p.dir, tempDir), "usr")
		local = ""
	} else {
		prefixDir = util.EnsureSubDir(util.EnsureSubDir(util.EnsureSubDir(p.dir, tempDir), "usr"), "local")
	}

	shareDir := util.EnsureSubDir(prefixDir, "share")

	binDir := util.EnsureSubDir(prefixDir, "bin")
	binName := filepath.Join(binDir, filepath.Base(p.exe))
	err := util.CopyExeFile(p.exe, binName)
	if err != nil {
		return fmt.Errorf("failed to copy application binary file: %w", err)
	}

Fyne version

2.2.4

Go compiler version

1.19.2

Operating system

Linux

Operating system version

Gentoo

Additional Information

It would be preferable to respect GOPATH and build apps in $GOPATH/bin, with a possibility of creating symlinks in /usr/local/bin/.
Also, note that /usr/local/bin may be writable for regular users on some systems, but it's not a standard behavior:
https://en.wikipedia.org/wiki/Filesystem_Hierarchy_Standard

@andydotxyz
Copy link
Member

The behaviour of "fyne get" is to install to the system specific application area - this are graphical app packages not go binaries. On windows this is Program Files and on macOS it is /Applications. This way the apps are findable in standard launchers.
Installing to the go binary location would not offer this benefit.
I agree that requiring sudo on some systems is undesirable, but I do not know what the alternative is?...

@andydotxyz andydotxyz added the question Further information is requested label Nov 24, 2022
@paboum
Copy link
Author

paboum commented Nov 24, 2022

If it respects GOPATH, and GOBIN, one can call it just like go:
GOBIN=/usr/local/bin/ go install
https://stackoverflow.com/questions/24069664/what-does-go-install-do

@andydotxyz
Copy link
Member

Fyne install is not like go install - it is not simply dripping the binary file in. It has metadata and package artefacts depending on OS

@Jacalz Jacalz removed the question Further information is requested label Nov 27, 2022
@Jacalz
Copy link
Member

Jacalz commented Nov 27, 2022

How about adding a flag like --local that installs into $HOME/.local? We are already doing something similar with the installation Makefile for the packaged Linux/BSD applications: https://github.com/fyne-io/fyne/blob/2c1d0bd8a00beedf283923ad1d91d519b822b858/cmd/fyne/internal/templates/data/Makefile#L30.

@andydotxyz
Copy link
Member

Maybe --user as that is a more generally understood term for user space installs?

@paboum
Copy link
Author

paboum commented Nov 27, 2022

Maybe --user as that is a more generally understood term for user space installs?

How about best effort, if there is no write access to /usr/local/bin, then try $HOME/.local/bin? Unless, of course, FYNEBIN env var doesn't point to somewhere else.

@andydotxyz
Copy link
Member

I don't think that it's a good idea to significantly change location based on permission setup.
Have you ever run a command and forgotten you need sudo? In this case it would potentially put the app in an unexpected place and exit with no error.

@Jacalz
Copy link
Member

Jacalz commented Nov 28, 2022

I agree. It is better to default to requiring sudo and then potentially give a suggestion, in the error message, to either elevate permissions (using sudo, doas, etc.) or use --user flag.

@paboum
Copy link
Author

paboum commented Dec 19, 2022

What information is still needed then?

@andydotxyz
Copy link
Member

It would be good to know if you are happy with with @Jacalz proposed. If so we can proceed.

@paboum paboum closed this as not planned Won't fix, can't repro, duplicate, stale Dec 21, 2022
@Jacalz Jacalz reopened this Dec 21, 2022
@Jacalz
Copy link
Member

Jacalz commented Dec 21, 2022

@paboum Why did you close this as not planned? I think it should stay open until the proposed feature has been implemented.

@NiceGuyIT
Copy link

I was attempting to install fyneterm when I ran across this issue. There are a few things that can be improved.

  1. Document the need for sudo.
  2. sudo ~/go/bin/fyne get github.com/fyne-io/terminal/cmd/fyneterm builds and installs the application as root leaving behind /root/go/{pkg/src}.
  3. Building as user and prompting for sudo/root access for installation is preferred.

@andydotxyz
Copy link
Member

Prompting for sudo would be ideal, however it is not clear how we know whether sudo or su is the setup for a local system - neither is universal. If you have hints and/or interest in creating a PR that would be excellent!

@Bluebugs
Copy link
Contributor

Maybe another approach is to detect the user we are running under and if it isn't root, we do the install as a user (our Unix Makefile support that with the user-install rule). That might be easier.

@Jacalz
Copy link
Member

Jacalz commented Feb 21, 2023

We have already discussed the solutions for this further up in this thread. I believe we already have a good idea for how to solve this

@Bluebugs
Copy link
Contributor

We have already discussed the solutions for this further up in this thread. I believe we already have a good idea for how to solve this

Oops, indeed.

@andydotxyz
Copy link
Member

Moving to the tools repo where this development is being picked up.

@andydotxyz andydotxyz transferred this issue from fyne-io/fyne Aug 1, 2024
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

5 participants