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

Unable to use absolute path to log file on Windows #13

Closed
d1vanloon opened this issue Dec 28, 2021 · 9 comments
Closed

Unable to use absolute path to log file on Windows #13

d1vanloon opened this issue Dec 28, 2021 · 9 comments
Labels
bug Something isn't working

Comments

@d1vanloon
Copy link

d1vanloon commented Dec 28, 2021

Summary

Setting an absolute path to the log file (the default) prevents the application from launching on Windows.

Steps to Reproduce

Environment: superhighway84 v0.0.4 on Windows build 22000.348

  1. Execute superhighway84.exe
  2. Accept the defaults for the Initial Setup prompts
  3. Specify a From name and accept other profile defaults

Expected Result

The application launches.

Actual Result

The application crashes with the following message:

SUPERHIGHWAY84

Initial Setup
-------------

Database connection string [/orbitdb/bafyreifdpagppa7ve45odxuvudz5snbzcybwyfer777huckl4li4zbc5k4/superhighway84]:
Database cache path [C:\Users\username/.cache/superhighway84]:
Logfile path [C:\Users\username/.cache/superhighway84.log]:

Profile information
-------------------

From [@localhost]: username123
Organization []:
2021/12/28 00:45:28 couldn't open sink "C:\\Users\\username/.cache/superhighway84.log": no sink found for scheme "c"
panic: couldn't open sink "C:\\Users\\username/.cache/superhighway84.log": no sink found for scheme "c"


goroutine 1 [running]:
log.Panicln({0xc00171ff50, 0x28, 0x29c6847bb11})
        /opt/hostedtoolcache/go/1.17.5/x64/src/log/log.go:368 +0x65
main.main()
        /home/runner/work/superhighway84/superhighway84/superhighway84.go:42 +0x1a5

Workaround

Set a relative path for the log file.

Unfortunately, this is not a permanent fix as the log file will be recreated several times based on the working directory from which the application was launched.

Notes

This seems related to parsing Windows paths in the logging module.

@altilunium
Copy link

altilunium commented Dec 28, 2021

Maybe related : uber-go/zap#621

@mrusme mrusme added the bug Something isn't working label Dec 28, 2021
@mrusme
Copy link
Owner

mrusme commented Dec 28, 2021

Oh boy, well, the zap situation kind of sucks. I actually didn't plan on using it, but I saw that OrbitDB and IPFS used it as Logger so I thought why not.

The error described here comes from my own code though, and I will be able to fox that. As for zap it seems IPFS have fixed it before: ipfs/go-log@45b384f

I'll likely take a similar approach to get it running. Thanks for pointing it out and providing further info!

@altilunium
Copy link

(Very crude) windows port, by me : https://github.com/altilunium/superhighway84

@mrusme
Copy link
Owner

mrusme commented Dec 28, 2021

Hey there @altilunium, thanks for getting it working! How about creating a proper PR for the changes, so we can incorporate them into the official release? :-)

@d1vanloon d1vanloon changed the title Unable to launch on Windows Unable to use absolute path to log file on Windows Dec 29, 2021
@d1vanloon
Copy link
Author

Based on previous discussion I updated the issue title and added a temporary workaround.

@mrusme
Copy link
Owner

mrusme commented Dec 29, 2021

Thanks! Maybe you want to give the current master a try. I've moved to filepath, which I believe should be OS-agnostic. I don't have a windows machine available for testing, so all I can do here is basically try things that should work in theory.

@d1vanloon
Copy link
Author

Tested on v0.0.5-4-g803fa84 with the following result:

SUPERHIGHWAY84

Initial Setup
-------------

Database connection string [/orbitdb/bafyreifdpagppa7ve45odxuvudz5snbzcybwyfer777huckl4li4zbc5k4/superhighway84]:
Database cache path [C:\Users\username\.cache\superhighway84]:
Logfile path [C:\Users\username\.cache\superhighway84.log]:

Profile information
-------------------

From [@localhost]: username123
Organization []:
2021/12/28 20:13:30 couldn't open sink "C:\\Users\\username\\.cache\\superhighway84.log": no sink found for scheme "c"
panic: couldn't open sink "C:\\Users\\username\\.cache\\superhighway84.log": no sink found for scheme "c"


goroutine 1 [running]:
log.Panicln({0xc001829f50, 0x28, 0x1d170100108})
        C:/Program Files/Go/src/log/log.go:368 +0x65
main.main()
        C:/Users/username/Source/Repos/github/mrusme/superhighway84/superhighway84.go:42 +0x1a5

This is a slightly different result - it looks like the paths are correctly formatted for Windows, but the log provider still can't interpret the path.

mrusme added a commit that referenced this issue Dec 29, 2021
@mrusme
Copy link
Owner

mrusme commented Dec 29, 2021

@d1vanloon if you don't mind you might test with the latest master again. I committed a changed to the NewLogger function which might fix the issue you're experiencing on Windows.

@d1vanloon
Copy link
Author

d1vanloon commented Dec 29, 2021

I tested on v0.0.6-3-g2781f76 and was unable to reproduce the issue. Thank you for investigating!

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

No branches or pull requests

3 participants