projg2 / pycargoebuild

A generator for Rust/Cargo ebuilds written in Python
GNU General Public License v2.0
28 stars 7 forks source link

Permission Denied #31

Closed lima-limon-inc closed 1 month ago

lima-limon-inc commented 1 month ago

When using pycargoebuild with no arguments (as stated by the wiki) I get the following error:

/var/cache/distfiles/leptos_macro-0.6.11.crate: Permission denied
Traceback (most recent call last):
  File "/usr/lib/python-exec/python3.12/pycargoebuild", line 8, in <module>
    sys.exit(entry_point())
             ^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pycargoebuild/__main__.py", line 438, in entry_point
    sys.exit(main(*sys.argv))
             ^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pycargoebuild/__main__.py", line 304, in main
    fetch_crates(crates)
  File "/usr/lib/python3.12/site-packages/pycargoebuild/__main__.py", line 204, in fetch_crates
    not try_fetcher("wget", fetch_crates_using_wget, crates)):
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.12/site-packages/pycargoebuild/__main__.py", line 193, in try_fetcher
    func(crates, distdir=args.distdir)
  File "/usr/lib/python3.12/site-packages/pycargoebuild/fetch.py", line 72, in fetch_crates_using_wget
    fetch_files_using_wget(
  File "/usr/lib/python3.12/site-packages/pycargoebuild/fetch.py", line 60, in fetch_files_using_wget
    subprocess.check_call(
  File "/usr/lib/python3.12/subprocess.py", line 413, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['wget', '-O', '/var/cache/distfiles/leptos_macro-0.6.11.crate', 'https://crates.io/api/v1/crates/leptos_macro/0.6.11/download']' returned non-zero exit status 1.

The error pops up regardless of how many times you run the command. AFAIK, it stems from the fact that my user only has read permissions for the /var/cache/distfiles/.

Calling pycargoebuild --help I found out that I needed to specify a "Directory to store downloaded crates in".

Now, either my user has to be in the portage group or I have to call this program as sudo. Is this understanding correct? Is that an intended feature?

If that's the case, maybe a little rewrite could be done to the wiki page: https://wiki.gentoo.org/wiki/Writing_Rust_ebuilds#Making_a_versioned_ebuild

An, another question, why the need to store these files in the distfiles directory? Wouldn't it make sense to store them in a newly created tmp/ directory by default? Or should those files be kept?

Thanks in advance and thank you for all your work.

mgorny commented 1 month ago

Yes, the tool is written with the assumption that you're able to access the distfiles directory on a development system. Unless I'm missing something, otherwise you won't be able to do stuff like updating Manifests anyway (since the PM won't be able to fetch distfiles).

It could put files elsewhere but that would be quite inefficient. The main point is to preserve them so that the subsequent PM invocation could use them. If pycargoebuild put them in a temporary directory, you'd have to fetch them again a minute later — and on top of that, pycargoebuild does fetching much faster than Portage does.

So yes, my advice would be to add your user to portage group, since otherwise you're going to have a hard time working on ebuilds anyway. If you really insist, you can give it another distfile directory but that definitely shouldn't be the default. Also, you may want to install net-misc/aria2 to fetch crates faster, given that crates.io is horribly slow.

lima-limon-inc commented 1 month ago

Yes, the tool is written with the assumption that you're able to access the distfiles directory on a development system. Unless I'm missing something, otherwise you won't be able to do stuff like updating Manifests anyway (since the PM won't be able to fetch distfiles).

It could put files elsewhere but that would be quite inefficient. The main point is to preserve them so that the subsequent PM invocation could use them. If pycargoebuild put them in a temporary directory, you'd have to fetch them again a minute later — and on top of that, pycargoebuild does fetching much faster than Portage does.

So yes, my advice would be to add your user to portage group, since otherwise you're going to have a hard time working on ebuilds anyway. If you really insist, you can give it another distfile directory but that definitely shouldn't be the default. Also, you may want to install net-misc/aria2 to fetch crates faster, given that crates.io is horribly slow.

Great to know, I'll add my user the portage group. Besides, I made a small clarification in the wiki page of cargo ebuild regading these permissions here.

Thank you very much mgorny!

Have a nice week :blush:

mgorny commented 1 month ago

Thanks!