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

v2 linux: SecondInstanceData.WorkingDirectory not initialized #3133

Closed
Vovan-VE opened this issue Dec 15, 2023 · 3 comments · Fixed by #3154
Closed

v2 linux: SecondInstanceData.WorkingDirectory not initialized #3133

Vovan-VE opened this issue Dec 15, 2023 · 3 comments · Fixed by #3154
Labels
Bug Something isn't working

Comments

@Vovan-VE
Copy link
Contributor

Description

v2.7 instoduced SingleInstanceLock, but on linux the SecondInstanceData.WorkingDirectory is always empty:

data := options.SecondInstanceData{
Args: os.Args[1:],
}

To Reproduce

func (a *App) secondInstance(data options.SecondInstanceData) {
	runtime.LogInfof(a.ctx, "%#v", data)
}
$ ./build/bin/linux-app ../foo.txt

Expected behaviour

INF | options.SecondInstanceData{Args:[]string{"../foo.txt"}, WorkingDirectory:"/abs/path"}

Screenshots

INF | options.SecondInstanceData{Args:[]string{"../foo.txt"}, WorkingDirectory:""}

Attempted Fixes

No response

System Details

# Wails
Version         | v2.7.1
Package Manager | apt   

# System
┌──────────────────────────────────────────────────────────────────────────────────┐
| OS           | Ubuntu                                                            |
| Version      | 22.04                                                             |
| ID           | ubuntu                                                            |
| Go Version   | go1.20.5                                                          |
| Platform     | linux                                                             |
| Architecture | amd64                                                             |
| CPU          | AMD Ryzen ...
| GPU          | unknown (Advanced Micro Devices, Inc. [AMD/ATI]) - Driver: amdgpu |
| Memory       | ..GB                                                              |
└──────────────────────────────────────────────────────────────────────────────────┘

# Dependencies
┌──────────────────────────────────────────────────────────────────────────┐
| Dependency | Package Name          | Status    | Version                 |
| *docker    | docker.io             | Available | 24.0.5-0ubuntu1~22.04.1 |
| gcc        | build-essential       | Installed | 12.9ubuntu3             |
| libgtk-3   | libgtk-3-dev          | Installed | 3.24.33-1ubuntu2        |
| libwebkit  | libwebkit2gtk-4.0-dev | Installed | 2.42.3-0ubuntu0.22.04.1 |
| npm        | npm                   | Installed | 9.5.1                   |
| *nsis      | nsis                  | Installed | v3.08-2                 |
| pkg-config | pkg-config            | Installed | 0.29.2                  |
└──────────────────────── * - Optional Dependency ─────────────────────────┘

# Diagnosis
Optional package(s) installation details: 
  - docker: sudo apt install docker.io

 SUCCESS  Your system is ready for Wails development!

Additional context

No response

@Vovan-VE Vovan-VE added the Bug Something isn't working label Dec 15, 2023
@Vovan-VE
Copy link
Contributor Author

It's inconsistent or incomplete. Looks same for windows:

data := options.SecondInstanceData{
Args: os.Args[1:],
}
serialized, _ := json.Marshal(data)

but different for darwin:
data, err := options.NewSecondInstanceData()
if err != nil {
return
}
serialized, err := json.Marshal(data)

func NewSecondInstanceData() (*SecondInstanceData, error) {
ex, err := os.Executable()
if err != nil {
return nil, err
}
workingDirectory := filepath.Dir(ex)
return &SecondInstanceData{
Args: os.Args[1:],
WorkingDirectory: workingDirectory,
}, nil
}

Using dir of executable in common case is not equal to CWD.

@leaanthony
Copy link
Member

@APshenkin - is this usage correct for this feature? Any assistance would be appreciated 🙏

@APshenkin
Copy link
Contributor

APshenkin commented Dec 17, 2023

Will take a look

leaanthony added a commit that referenced this issue Jan 3, 2024
* [#3133] SingleInstanceData: Fill missing WD as is

* Apply suggestions from code review

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>

* Fix: missing `import` for AI suggestions

* Add changelog entry

---------

Co-authored-by: Lea Anthony <[email protected]>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants