Problem with user rights?

Hi,

I've installed Cudatext (text editor) in QT version using pkg. It uses Python for scripting and addons, so you need to set the path to the Python libraries in the system; /usr/local/lib/. The problem is that the program has also its own Python directory; ~/.config/cudatext/py/ created by the program, but seems that it can't set this directory in the start-up (all Python addons/modules give an error).

Running the program as superuser in a terminal gives no error, and it set its Python directory correctly; /root/.config/cudatext/py/ and /root/.config/cudatext/py/sys

A problem with the user rights?
Muy user is in wheel and video groups.
 
Hi!

Have you tried running Cudatext from Konsole and seeing any errors thrown?

What about ls -ld /root and ls -ld $HOME.. and .config?

chmod o+x $HOME made a difference?
 
Have you tried running Cudatext from Konsole and seeing any errors thrown?

Yes, no error. The program starts without problem, the error is shown in the terminal of the program when It tries to load a Python module/addon.

What about ls -ld /root and ls -ld $HOME.. and .config?

All the same, rwxr-xr-x. In $HOME and .config owner and group is the same (my username).

chmod o+x $HOME made a difference?

No, no difference.

Thanks for the response!
 
Try eventually chmod 777...
Not sure if it will work.

I've just checked the permissions in my Debian installation (Cudatex works fine there) and in root/.config and ~/.config the permissions are; rwx------

The software autor told me that CudaText code has a procedure that adds py-dir to sys.path.
procedure TfmMain.PythonEngineAfterInit(Sender: TObject) (Free Pascal).

But he has not a clue why is not working in FreeBSD. Maybe the package has been changed? Should I ask to the package maintainer?
 
Why? addons calling home?
Already ran it as root.
You already know it's a permission issue, setting the permissions to 777 won't add new information. And there's a big risk it'll work with 777 and then never changed. World-writable files or directories are a huge security risk.
 
One idea I have for this issue:

OP could try running it as root - and then tell the program to look elsewhere for the config file, like in /usr/local/etc/... like via the Options menu in the CudaText window... After making that change, run CudaText as regular user.

Also, consider workable alternatives... the Ports Collection has lots of them, I personally like editors/kate and editors/nano... The Kate editor has lots of features that rival anything available in editors/cudatext...
 
In a secure setup
Code:
chown root:wheel /root
chmod 700 /root
So anything in the "/root" directory is not readable by all regular users who are not root.

If you need to install python packages as a regular user you can use pip.
And add it to the path as needed.
 
OP could try running it as root - and then tell the program to look elsewhere for the config file, like in /usr/local/etc/... like via the Options menu in the CudaText window... After making that change, run CudaText as regular user.
I did not find any option to change the route to config files, neither in options window nor in .json file (default.json).

I can use the portable version also, but it is based in gtk and it has some visual and performance issues with Plasma. Kate it's a great editor (the one I'm using now in FreeBSD), but I have CudaText in my Windows (work laptop) and Debian systems and is very comfortable to use the same editor with the same settings.

I also have a special fondness for CudaText, through it, I discovered how efficient and fast is to have all (or most) the configurations in text files... and got me interested in systems with the same philosophy, like FreeBSD.
 
In a secure setup
Code:
chown root:wheel /root
chmod 700 /root
So anything in the "/root" directory is not readable by all regular users who are not root.

If you need to install python packages as a regular user you can use pip.
And add it to the path as needed.

CudaText manages the installation of the Python modules and addons that it uses. The problem is that it needs also Python, so I gives an error as soon as you use it.
 
One very ugly workaround is to enable write access from a regular user to the system python paths where cudatext wants to write.
Note the system python packages will be unaware of these packages installed by cudatext. So there is the danger of overwrites/conflicts/different versions of the same software.

And a link fyi,
 
What is the error?

In the program console:

Code:
ModuleNotFoundError: No module named ¨cuda_addonman´
ERROR: Exception in CudaText for cuda_addonman.do_install_addon:
ModuleNotFoundError: No module named ¨cuda_addonman

Python directories running with my user (uses usr/local/bin instead of ~/.config/cudatext).
Code:
['/usr/local/bin', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']

Python directories running as root.
Code:
['/usr/home/myuser/.config', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']

Don't know why is using /usr/home/myuser/.config and not /root/.config.

Permissions:
~/.config/cudatext/py; rwxr-xr-x
~/.config/cudatext; rwxr-xr-x
Group and user; my username.
 
Python directories running with my user (uses usr/local/bin instead of ~/.config/cudatext).
Code:
['/usr/local/bin', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']

Python directories running as root.
Code:
['/usr/home/myuser/.config', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']

Don't know why is using /usr/home/myuser/.config and not /root/.config.
How are you getting this output? What does echo $PYTHONPATH output both as root and as your user?

Permissions:
~/.config/cudatext/py; rwxr-xr-x
~/.config/cudatext; rwxr-xr-x
Group and user; my username.
What about files inside those directories. Are they owned by root?
 
Hobbes, which version of editors/cudatext are you running?

There seems to be a problem with the 1.187.1 qt5 version from the "quarterly" ports/packages branch (since the package is build from that branch, automatically the application installed as package is affected as well).

This Github issue is about "BSD package installer must copy folders 'data' and 'py' to ~/.config/cudatext , which is not done yet.", with similar error messages you are describing:

On Launch, the button status says ‘ModuleNotFoundError: No module named 'cuda_tabs_list', and the left side window titled ‘tabs’ is empty.
When I select Open Folder, I get ‘ModuleNotFoundError: No module named 'cuda_project_man'
ERROR: Exception in CudaText for cuda_project_man.new_project_open_dir: ModuleNotFoundError: No module named 'cuda_project_man'

Version 1.191.5 from the "latest" ports/packages is not affected what you are describing. I have the application installed (cudatext-qt5 flavor), no problem here. From the applications "Addon Manager" installed addons are placed under the users ~/.config/cudatext/py directory.

See also PR 271221
 
How are you getting this output?
Hobbes, which version of editors/cudatext are you running?

In CudaText console:
Code:
import sys
print(sys.path)

What does echo $PYTHONPATH output both as root and as your user?
As root: PYTHONPATH: Variable indefinida it means; undefined variable.
As user: a black line, no text.

What about files inside those directories. Are they owned by root?
By user.

which version of editors/cudatext are you running?

I have the latest ports/packages and CudaText 1.191.5.0, freebsd-x86_64-qt5, fpc 3.2.2.

If you have no problems, something is wrong with my configuration.
 
In CudaText console:
Code:
import sys
print(sys.path)
Interesting, so Cudatext has a built-in Python REPL. What happens if you run those same commands in the regular Python REPL? Here's what it reports on my system
Code:
 $ python3.9
Python 3.9.16 (main, Apr  2 2023, 01:13:51) 
[Clang 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']
>>>

I have the latest ports/packages and CudaText 1.191.5.0, freebsd-x86_64-qt5, fpc 3.2.2.
Just got updated to 1.194.0 a couple of days ago
Not sure upgrading would solve your problem.

There's a mention of a user.json here. I don't use Cudatext, so I don't have one. Maybe the mysterious Python path settings are in there.
 
Interesting, so Cudatext has a built-in Python REPL. What happens if you run those same commands in the regular Python REPL? Here's what it reports on my system
Code:
 $ python3.9
Python 3.9.16 (main, Apr  2 2023, 01:13:51)
[Clang 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']
>>>


Just got updated to 1.194.0 a couple of days ago
Not sure upgrading would solve your problem.

There's a mention of a user.json here. I don't use Cudatext, so I don't have one. Maybe the mysterious Python path settings are in there.
Same output:

Code:
Python 3.9.16 (main, Apr  2 2023, 01:13:51)  
[Clang 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']
>>>

Not sure upgrading would solve your problem.
Nop, same issue.

Maybe the mysterious Python path settings are in there.
In my user.json I've put the directory of Python libs (following the instructions of CudaText wiki and the program indications).

"pylib__freebsd" : "/usr/local/lib/libpython3.9.so.1",

And nothing.
 
Same output:

Code:
Python 3.9.16 (main, Apr  2 2023, 01:13:51) 
[Clang 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a on freebsd13
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys
>>> print(sys.path)
['', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']
>>>
Doesn't look the same to me:

Python directories running with my user (uses usr/local/bin instead of ~/.config/cudatext).
Code:
['/usr/local/bin', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']

Python directories running as root.
Code:
['/usr/home/myuser/.config', '/usr/local/lib/python39.zip', '/usr/local/lib/python3.9', '/usr/local/lib/python3.9/lib-dynload', '/usr/local/lib/python3.9/site-packages']
 
Doesn't look the same to me:
Sorry, I mean same as your output.

Maybe $XDG_CONFIG_HOME is set?

I've taken a look to ~.profile, ~shrc and /etc/login.conf and is not set, but I am newbie in FreeBSD (or Linux) and I don't know if I should look in other places, sorry. One of the reason for not give up this problem is because I want to understand the cause and learn more about FreeBSD.

Thanks for the reference, I missed that line about $XDG_CONFIG_HOME.
 
You could see what Python is getting inside Cudatext like this:
Code:
>>> import os
>>> print(os.environ)
environ({'LOGNAME': 'me', 'LANG': 'C.UTF-8', 'PAGER': 'less', 'COLORFGBG': '15;default;0', 'MAIL': '/var/mail/me', 'PATH': '/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/home/me/bin', 'EDITOR': 'vi', 'ENV': '/home/me/.shrc', 'OLDPWD': '/usr/home/me', 'DISPLAY': ':0', 'PWD': '/home/me', 'TERM': 'rxvt', 'USER': 'me', 'HOME': '/home/me', 'WINDOWPATH': '9', 'SHELL': '/bin/sh', 'COLORTERM': 'rxvt-xpm', 'MM_CHARSET': 'UTF-8', 'WINDOWID': '20971526', 'BLOCKSIZE': 'K'})
 
Back
Top