RaySession
RaySession copied to clipboard
Can't create new session: permission denied.
First, thanks for this great tool. I'm trying to package RaySession for NixOs. It works pretty well so far, except one issue: it's not possible to create a new project since the template is copied read-only (the path in which Ray is installed is read only for mutliple reasons in NixOs).
$ result/bin/raysession
Qt: Session management error: Could not open network socket
[ray-daemon]GUI connected at osc.udp://bestos:15341/
[ray-daemon]URL : osc.udp://192.168.1.54:16188/
[ray-daemon] osc.udp://bestos:16188/
[ray-daemon]ROOT: /home/me/Ray Sessions
Traceback (most recent call last):
File "/nix/store/3mnnplv972pwm06wqlxcc77r5n9fmmvs-RaySession-0.11.1/share/raysession/src/daemon/file_copier.py", line 133, in _process_finished
self._next_function(*self._next_args)
File "/nix/store/3mnnplv972pwm06wqlxcc77r5n9fmmvs-RaySession-0.11.1/share/raysession/src/daemon/session.py", line 1664, in prepare_template_substep1
self.adjust_files_after_copy(new_session_full_name,
File "/nix/store/3mnnplv972pwm06wqlxcc77r5n9fmmvs-RaySession-0.11.1/share/raysession/src/daemon/session.py", line 1050, in adjust_files_after_copy
ray_file_w = open(session_file, 'w')
PermissionError: [Errno 13] Permission denied: '/home/me/Ray Sessions/test/raysession.xml'
I guess RaySession just copy the file and does not change the permissions. Would it be possible to adapt the code to make sure it works when install path is readonly?
Thanks!
For reference, here is the derivation I created so far:
{ mkDerivation,
lib,
stdenv,
fetchFromGitHub,
jack2,
which,
python3,
qtbase,
qttools,
# wrapQtAppsHook,
liblo,
git,
}:
let
myPython = python3.withPackages (pkgs: with pkgs; [ pyqt5 liblo pyliblo pyxdg ]);
in
mkDerivation rec {
pname = "RaySession";
version = "0.11.1";
src = fetchFromGitHub {
owner = "Houston4444";
repo = pname;
# rev = "v${version}";
rev = "b2724aafbc794e08ae5d69249e42aeaec15ced61";
sha256 = "sha256-EbDBuOcF0JQq/LOrakb040Yfrpdi3FOB1iczQTeXBkc=";
};
postPatch = ''
substituteInPlace Makefile \
--replace "lrelease-qt4" "${qttools.dev}/bin/lrelease" \
--replace '$(DESTDIR)/' '$(DESTDIR)$(PREFIX)' # Otherwise problem since it tries to install the manual in /etc instead of /nix/...
'';
nativeBuildInputs = [
myPython
# wrapQtAppsHook
which
qttools
];
propagatedBuildInputs = [ myPython qtbase jack2 git ];
makeFlags = [ "PREFIX=$(out)" ];
}
EDIT After investigation, the issue comes from the lines in file_copier.py:
self._process.start('nice',
['-n', '+15', 'cp', '-R',
copy_file.orig_path, copy_file.dest_path])
on just needs to add a '--no-preserve=mode,ownership', option. The patch is now:
diff --git a/src/daemon/file_copier.py b/src/daemon/file_copier.py
index b0c805b..d5ea55f 100644
--- a/src/daemon/file_copier.py
+++ b/src/daemon/file_copier.py
@@ -147,7 +147,7 @@ class FileCopier(ServerSender):
if copy_file.state == 0:
copy_file.state = 1
self._process.start('nice',
- ['-n', '+15', 'cp', '-R',
+ ['-n', '+15', 'cp', '-R', '--no-preserve=mode,ownership',
copy_file.orig_path, copy_file.dest_path])
break
and the derivation
# https://github.com/Houston4444/RaySession
# alternative to NSM
{ mkDerivation,
lib,
stdenv,
fetchFromGitHub,
jack2,
which,
python3,
qtbase,
qttools,
# wrapQtAppsHook,
liblo,
git,
}:
let
myPython = python3.withPackages (pkgs: with pkgs; [ pyqt5 liblo pyliblo pyxdg ]);
in
mkDerivation rec {
pname = "RaySession";
version = "0.11.1";
src = fetchFromGitHub {
owner = "Houston4444";
repo = pname;
# rev = "v${version}";
rev = "b2724aafbc794e08ae5d69249e42aeaec15ced61";
sha256 = "sha256-EbDBuOcF0JQq/LOrakb040Yfrpdi3FOB1iczQTeXBkc=";
};
patches = [ ./copy_template_writable.patch ];
postPatch = ''
substituteInPlace Makefile \
--replace "lrelease-qt4" "${qttools.dev}/bin/lrelease" \
--replace '$(DESTDIR)/' '$(DESTDIR)$(PREFIX)' # Otherwise problem with installing manual etc...
'';
nativeBuildInputs = [
myPython
# wrapQtAppsHook
which
qttools
];
propagatedBuildInputs = [ myPython qtbase jack2 git ];
# Prefix must be set correctly due to sed -i "s?X-PREFIX-X?$(PREFIX)?"
#
makeFlags = [ "PREFIX=$(out)" ]; # prefix does not work since due to line "install -d $(DESTDIR)/etc/xdg/"
# dontWrapQtApps = true; # We will do it manually because of scripts...
# preFixup = ''
# wrapQtApp "$out/bin/raysession"
# '';
# dontWrapGApps = true;
# # Arguments to be passed to `makeWrapper`, only used by qt5’s mkDerivation
# preFixup = ''
# qtWrapperArgs+=("''${gappsWrapperArgs[@]}")
# wrapQtApp "$out/bin/raysession"
# '';
# meta = with lib; {
# homepage = "https://github.com/guysherman/jack-passthrough";
# description = "";
# longDescription = ''
# '';
# license = licenses.;
# maintainers = with maintainers; [ ];
# platforms = platforms.;
# };
}
Ok, I just submitted a PR.
Hi! Thanks a lot to have found the issue yourself. RS is normally installed in a read only path, so it is probable that nixos use a différent version of cp. I have no time this week to investigate, I'll take a look next week. Cheers
Is it really needed to lock permissions on installed path in NixOs ? RaySession is certainly not the only one program which copies files from its code path to the user path. I mean, in almost distributions, code path belongs to another user (root).
Yes, it's quite fundamental to ensure the path is write only (actually I think it's actually a bind read-only mount but I could be wrong). They do that to make sure program code is immutable. I'm not aware of another solution than patching upstream programs, but I could be wrong.
I'm also running into this. Instead of the cp command, could RaySession use cat template.xml > dest.xml? Or perhaps chmod 644 it after it's copied? What @tobiasBora suggested would work fine too.
Hi !
could RaySession use cat template.xml > dest.xml?
Not at all, session template is a folder, it can contain many files.
Or perhaps
chmod 644it after it's copied?
With this, executables are not executables anymore, it breaks session scripts.
What @tobiasBora suggested would work fine too.
No, for the same reason.
I am sorry to not found any good solution. An alternative could be to check which files are executable, make the copy with --no-preserve=mode,ownership, then chmod +x on needed files. This should be applied only on Factory session templates, because a session can contain files from various programs, and it is not possible to be sure that this change could not break something else with another program.
Ah, I see. Thanks for explaining. What about another solution, after copying template files for the project, how about running chmod -R +w the folder, so their write bit is set. Immutable linux distros still maintain the R and X bits for files, just not the W bit.
how about running chmod -R +w the folder, so their write bit is set.
Ah, It may be the good solution !
I suppose that the problem also happens when we add a factory client with some data copied (for example CalfJackHost or QMidiRoute), could you confirm ?
Ok, I've done it. Could you please try the nixos_chmod branch (https://github.com/Houston4444/RaySession/tree/nixos_chmod) and confirm it works ?
There appear to be no adverse effects.
Yay! It works! Here's a fresh project generated from the scripts template:
Looks good to me!
Ok ! It is merged to master.