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 run from /opt/grayjay #167

Open
3 tasks
ggodlewski opened this issue Dec 26, 2024 · 13 comments
Open
3 tasks

Unable to run from /opt/grayjay #167

ggodlewski opened this issue Dec 26, 2024 · 13 comments
Labels
Bug Something isn't working Desktop Linux

Comments

@ggodlewski
Copy link

What happened?

I moved grayjay to /opt and removed Portable file

After running /opt/Grayjay.Desktop-linux-x64-v2/Grayjay --no-sandbox I'm getting:

CEF:File not found at native path '/home/gg/cef/dotcefnative'.

After copying this directory I'm getting:

System.IO.DirectoryNotFoundException: /home/gg/wwwroot/

Grayjay Version

2

What plugins are you seeing the problem on?

All

Plugin Version

No response

Which operating system are you using?

Linux

When do you experience the issue?

  • While logged in
  • While logged out
  • N/A

Are you using a VPN?

No

Relevant log output

No response

@ggodlewski ggodlewski added the Bug Something isn't working label Dec 26, 2024
@nathanchere
Copy link

There is also the issue of the application writing logs to the installation path, so if you move to /opt/grayjay it will try to write logs under /opt/grayjay. Running under /opt/ will need some more work.

@cheetah2003
Copy link

Put:

cd /opt/Grayjay.Desktop-linux-x64-v2
./Grayjay --no-sandbox

It'll work as expected. It really wants the current directory to be where it lives when you start it.
However, it's true it wants to be able to write to it's installation location. Not very Linux-like behavior there.

@nathanchere
Copy link

Put:

cd /opt/Grayjay.Desktop-linux-x64-v2
./Grayjay --no-sandbox

It'll work as expected.

Not for me. It still gives:

[build@niflheim5 ~]$ cd /opt/grayjay && exec ./Grayjay --no-sandbox
Unhandled exception. System.TypeInitializationException: The type initializer for 'Grayjay.Desktop.POC.Logger' threw an exception.
 ---> System.UnauthorizedAccessException: Access to the path '/opt/grayjay/log.txt' is denied.
 ---> System.IO.IOException: Permission denied

@cheetah2003
Copy link

See the other part of my comment. It needs to write to its directory. So you will need to ensure the permissions allow this.

@ggodlewski
Copy link
Author

It really wants the current directory to be where it lives when you start it.

Oh, so that is the reason why it doesn't work from Mate's custom application launcher icon. I would have to create a script. Damn it.

@Zvonimir-FUTO Zvonimir-FUTO added the Solved Issue/feature has been fixed/implemented in development branch but not yet pushed to end users label Jan 13, 2025
@Zvonimir-FUTO
Copy link
Collaborator

Done. It now checks to see if the old style dir exists first and then uses that. Otherwise, it will use a new style dir which prioritizes:

  1. XDG_DATA_HOME
  2. ~/.local.share
  3. ~/.config

Depending on what exists.

This will be released in the next update.

@Zvonimir-FUTO
Copy link
Collaborator

Implemented in latest version.

@ggodlewski
Copy link
Author

I tried V4, still failing:

$ /opt/Grayjay.Desktop-linux-x64-v4/Grayjay 
Unhandled exception. System.TypeInitializationException: The type initializer for 'Grayjay.Desktop.POC.Logger' threw an exception.
 ---> System.UnauthorizedAccessException: Access to the path '/opt/Grayjay.Desktop-linux-x64-v4/log.txt' is denied.
 ---> System.IO.IOException: Permission denied
   --- End of inner exception stack trace ---
   at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String path, OpenFlags flags, Int32 mode, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
   at System.IO.Strategies.OSFileStreamStrategy..ctor(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, Nullable`1 unixCreateMode)
   at System.IO.StreamWriter.ValidateArgsAndOpenPath(String path, Boolean append, Encoding encoding, Int32 bufferSize)
   at System.IO.StreamWriter..ctor(String path, Boolean append)
   at Grayjay.Desktop.POC.Logger..cctor()
   --- End of inner exception stack trace ---
   at Grayjay.Desktop.POC.Logger.i(String tag, String msg)
   at Grayjay.Desktop.Program.Main(String[] args)
   at Grayjay.Desktop.Program.<Main>(String[] args)
Aborted (core dumped)

/opt should be readonly, logs should be written under /home

@Zvonimir-FUTO Zvonimir-FUTO reopened this Jan 22, 2025
@Zvonimir-FUTO
Copy link
Collaborator

Can you try deleting Portable file? This will force Grayjay to use following locations for storing files:

  1. XDG_DATA_HOME
  2. ~/.local.share
  3. ~/.config

@ggodlewski
Copy link
Author

I removed Portable (I think there should be a warning in console if the file exists while running from /opt):

The current error is:

/opt/Grayjay.Desktop-linux-x64-v4/Grayjay 
Directories:Base Directory: /home/gg/.local/share/Grayjay
Directories:Temporary Directory: /home/gg/.local/share/Grayjay/temp_files
Directories:Log file path: /home/gg/.local/share/Grayjay/log.txt
T:PortFile path: /home/gg/.local/share/Grayjay/port
T:StartingUpFile path: /home/gg/.local/share/Grayjay/starting
T:Found StartingUpFile, waiting for PortFile and process
T:No PortFile after waiting, killing any lingering (stuck) process
T:Created StartingUpFile, removed PortFile
Program:Main: StateApp.Startup
StateApp:Startup: Initializing PluginEncryptionProvider
StateApp:Startup: Initializing DatabaseConnection
StateApp:Startup: Ensuring Table DBSubscriptionCache
StateApp:Startup: Ensuring Table DBHistory
StateApp:Startup: Initializing Download Cycle
StateDownloads:Started downloading cycle
StateDownloads:Ended downloading cycle
Program:Main: StateApp.Startup finished (90ms)
Program:Extra args: 
Program:Main: Starting DotCefProcess
CEF:Searching for dotcefnative, search paths:
CEF: - /opt/Grayjay.Desktop-linux-x64-v4/cef/dotcefnative
CEF: - /opt/Grayjay.Desktop-linux-x64-v4/dotcefnative
CEF: - /home/gg/dotcefnative
CEF: - /home/gg/cef/dotcefnative
CEF:Working directory '/home/gg/cef'.
CEF:CEF exe path '/home/gg/cef/dotcefnative'.
--change-stack-guard-on-fork=disable --disable-chrome-runtime --parent-to-child 111 --child-to-parent 114 --disable-web-security --use-views --no-sandbox 
Program:Main: Starting DotCefProcess finished (6ms)
Program:Main: Starting window.
Receive loop started.
GrayjayServer:RunServerAsync: Called with (proxyUrl = ).
CEF:[0122/131600.842449:INFO:pipe.cc(141)] Pipe set handles readFd 111, writeFd 114
CEF:[0122/131600.842581:INFO:main_linux.cc(149)] Cache path: /tmp/dotcef_1737548160842
CEF:[0122/131600.843182:ERROR:chrome_main_delegate.cc(1200)] Web security may only be disabled if '--user-data-dir' is also specified with a non-default value.
CEF:main with processType = 1.
CEF:Argument 0: '/home/gg/cef/dotcefnative'.
CEF:Argument 1: '--type=zygote'.
CEF:Argument 2: '--no-zygote-sandbox'.
CEF:Argument 3: '--no-sandbox'.
CEF:Argument 4: '--string-annotations'.
CEF:Argument 5: '--enable-crash-reporter=,'.
CEF:Argument 6: '--user-data-dir=/tmp/dotcef_1737548160842'.
Received notification Ready
Client is ready.
Received notification WindowOpened
Window opened: 1
Received notification WindowFocused
Program:Main: Starting window finished (276ms)
Program:Main: Waiting for ASP to start.
Received notification WindowLoadStart
Received notification WindowLoadEnd
GrayjayServer:RunServerAsync: Static files path '/home/gg/wwwroot'.
Program:Main: Unhandled error in RunServerAsync.
System.IO.DirectoryNotFoundException: /home/gg/wwwroot/
   at Microsoft.Extensions.FileProviders.PhysicalFileProvider..ctor(String root, ExclusionFilters filters)
   at Grayjay.ClientServer.GrayjayServer.RunServerAsync(String proxyUrl, CancellationToken cancellationToken)
   at Grayjay.Desktop.Program.<>c__DisplayClass13_0.<<Main>b__3>d.MoveNext()

@Zvonimir-FUTO Zvonimir-FUTO removed the Solved Issue/feature has been fixed/implemented in development branch but not yet pushed to end users label Jan 22, 2025
@MoralCode
Copy link

MoralCode commented Mar 2, 2025

im experiencing this too in #14

i think the cause is around here

Logger.i(nameof(GrayjayServer), $"RunServerAsync: Static files path '" + Path.GetFullPath(staticFilesPath) + "'.");

Looks like Path.GetFullPath("wwwroot"); doesnt work correctly on linux and somehow returns /home/<user>/wwwroot, rather than relying on Directories.cs which now respects XDG_DATA_HOME per #221

also the docs for Path.GetFullPath say:

Output is based on your current directory

so maybe theres a workaround or something

Ultimately the solution may be as simple as changing to Path.GetFullPath("wwwroot", Directory.Base); or similar

@MoralCode
Copy link

A similar issue seems to be present at

window = cef.CreateWindowAsync("about:blank", ((int)(900)), ((int)(550)), ((int)(1300)), ((int)(950)), title: "Grayjay", iconPath: Path.GetFullPath("grayjay.png"), appId: "com.futo.grayjay.desktop").Result;
regarding the path to grayjay.png. All uses of Path.GetFullPath may need to be checked and set up to use the existing base directory that respects XDG_DATA_HOME

@MoralCode
Copy link

i am mistaken. Both of these instances are expecting a path in the installation directory, not the user data directory.

however, this instance

File.WriteAllText("launch", Path.GetFileName(p.MainModule!.FileName));
expects to be in the user data directory

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Desktop Linux
Projects
None yet
Development

No branches or pull requests

5 participants