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

Show rosdep-fix-permissions advice when cache read fails. #787

Merged
merged 3 commits into from
Jun 25, 2021

Conversation

nuclearsandwich
Copy link
Contributor

By re-raising this IOError as a CachePermissionsError the advice to run
rosdep fix-permissions will be displayed instead of the general
stacktrace.

If rosdep update is run as root and then a command like rosdep resolve
is used to read from the cache rather than write to it this stacktrace
occurs as reported in #782.

Before

❯ rosdep resolve python

ERROR: Rosdep experienced an error: [Errno 13] Permission denied: '/home/steven/.ros/rosdep/sources.cache/index'
Please go to the rosdep page [1] and file a bug report with the stack trace below.
[1] : http://www.ros.org/wiki/rosdep

rosdep version: 0.20.0

Traceback (most recent call last):
  File "/home/steven/osrf/rosdep/src/rosdep2/main.py", line 144, in rosdep_main
    exit_code = _rosdep_main(args)
  File "/home/steven/osrf/rosdep/src/rosdep2/main.py", line 426, in _rosdep_main
    return _rosdep_args_handler(command, parser, options, args)
  File "/home/steven/osrf/rosdep/src/rosdep2/main.py", line 448, in _rosdep_args_handler
    return command_handlers[command](args, options)
  File "/home/steven/osrf/rosdep/src/rosdep2/main.py", line 853, in command_resolve
    lookup = _get_default_RosdepLookup(options)
  File "/home/steven/osrf/rosdep/src/rosdep2/main.py", line 132, in _get_default_RosdepLookup
    sources_loader = SourcesListLoader.create_default(sources_cache_dir=options.sources_cache_dir,
  File "/home/steven/osrf/rosdep/src/rosdep2/sources_list.py", line 603, in create_default
    sources = load_cached_sources_list(sources_cache_dir=sources_cache_dir, verbose=verbose)
  File "/home/steven/osrf/rosdep/src/rosdep2/sources_list.py", line 561, in load_cached_sources_list
    with open(cache_index, 'r') as f:
PermissionError: [Errno 13] Permission denied: '/home/steven/.ros/rosdep/sources.cache/index'

After

❯ rosdep resolve python
Failed to write cache file: [Errno 13] Permission denied: '/home/steven/.ros/rosdep/sources.cache/index'
Try running 'sudo rosdep fix-permissions'

By re-raising this IOError as a CachePermissionsError the advice to run
rosdep fix-permissions will be displayed instead of the general
stacktrace.

If rosdep update is run as root and then a command like rosdep resolve
is used to read from the cache rather than write to it this stacktrace
occurs as reported in #782.
Copy link
Member

@cottsay cottsay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One minor suggestion, but this looks good to me.

src/rosdep2/sources_list.py Show resolved Hide resolved
nuclearsandwich and others added 2 commits June 25, 2021 11:07
This reverts commit f8bc193.

Python 2 does not support this expression.
@nuclearsandwich nuclearsandwich merged commit 36cc982 into master Jun 25, 2021
@nuclearsandwich nuclearsandwich deleted the cache-error-on-read branch June 25, 2021 19:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants