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

watson config -e crashes if no config already exists #153

Closed
jbarnoud opened this issue Jun 16, 2017 · 3 comments
Closed

watson config -e crashes if no config already exists #153

jbarnoud opened this issue Jun 16, 2017 · 3 comments

Comments

@jbarnoud
Copy link
Contributor

When calling watson config -e to edit a configuration file, I get the following error message:

Traceback (most recent call last):
  File "/home/jon/Envs/watson/bin/watson", line 11, in <module>
    load_entry_point('td-watson', 'console_scripts', 'watson')()
  File "/home/jon/Envs/watson/lib/python3.6/site-packages/pkg_resources/__init__.py", line 561, in load_entry_point
    return get_distribution(dist).load_entry_point(group, name)
  File "/home/jon/Envs/watson/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2649, in load_entry_point
    return ep.load()
  File "/home/jon/Envs/watson/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2303, in load
    return self.resolve()
  File "/home/jon/Envs/watson/lib/python3.6/site-packages/pkg_resources/__init__.py", line 2309, in resolve
    module = __import__(self.module_name, fromlist=['__name__'], level=0)
  File "/home/jon/dev/Watson/watson/__main__.py", line 6, in <module>
    cli.cli()
  File "/home/jon/Envs/watson/lib/python3.6/site-packages/click/core.py", line 722, in __call__
    return self.main(*args, **kwargs)
  File "/home/jon/Envs/watson/lib/python3.6/site-packages/click/core.py", line 697, in main
    rv = self.invoke(ctx)
  File "/home/jon/Envs/watson/lib/python3.6/site-packages/click/core.py", line 1066, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/jon/Envs/watson/lib/python3.6/site-packages/click/core.py", line 895, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/jon/Envs/watson/lib/python3.6/site-packages/click/core.py", line 535, in invoke
    return callback(*args, **kwargs)
  File "/home/jon/Envs/watson/lib/python3.6/site-packages/click/decorators.py", line 17, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/jon/dev/Watson/watson/cli.py", line 825, in config
    with open(watson.config_file) as fp:
FileNotFoundError: [Errno 2] No such file or directory: '/home/jon/.config/watson/config'

If the config file already exists, then everything works as expected.

The behaviour I would expect when the config file does not exist would be that the editor is opened whith an empty file, and the config file is created if something is saved.

@jmaupetit
Copy link
Contributor

Thanks for the report @jbarnoud! Do not hesitate to submit a PR to fix this 😉

SpotlightKid added a commit to SpotlightKid/Watson that referenced this issue Jun 16, 2017
fixes jazzband#153)

Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
SpotlightKid added a commit that referenced this issue Jun 19, 2017
fixes #153) (#154)

Signed-off-by: Christopher Arndt <chris@chrisarndt.de>
@thiborose
Copy link

thiborose commented Oct 4, 2022

Hi, the issue is still present for me (installed on windows powershell, release and dev version)

(base) PS C:\windows\system32> watson config -e
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\miniforge3\lib\shutil.py", line 823, in move
os.rename(src, real_dst)
FileNotFoundError: [WinError 3] The system cannot find the path specified:
'C:\\Users\\xxx\\AppData\\Local\\Temp\\tmpaw14iuyy' -> 'C:\\Users\\xxx\\AppData\\Roaming\\watson\\config'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\xxx\AppData\Local\miniforge3\Scripts\watson-script.py", line 33, in <module>
sys.exit(load_entry_point('td-watson', 'console_scripts', 'watson')())
File "C:\Users\xxx\AppData\Local\miniforge3\Scripts\watson-script.py", line 25, in importlib_load_entry_point
return next(matches).load()
File "C:\Users\xxx\AppData\Local\miniforge3\lib\importlib\metadata.py", line 86, in load
module = import_module(match.group('module'))
File "C:\Users\xxx\AppData\Local\miniforge3\lib\importlib\__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 850, in exec_module
File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
File "c:\users\xxx\code\watson\watson\__main__.py", line 3, in <module>
cli.cli()
"C:\Users\xxx\AppData\Local\miniforge3\lib\site-packages\click\core.py", line 1130, in __call__
return self.main(*args, **kwargs)
File "C:\Users\xxx\AppData\Local\miniforge3\lib\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
File "C:\Users\xxx\AppData\Local\miniforge3\lib\site-packages\click\core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "C:\Users\xxx\AppData\Local\miniforge3\lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "C:\Users\xxx\AppData\Local\miniforge3\lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
File "C:\Users\xxx\AppData\Local\miniforge3\lib\site-packages\click\decorators.py", line 26, in new_func
return f(get_current_context(), *args, **kwargs)
File "c:\users\xxx\code\watson\watson\cli.py", line 136, in wrapper
return func(*args, **kwargs)
File "c:\users\xxx\code\watson\watson\cli.py", line 1465, in config
safe_save(watson.config_file, newconfig)
File "c:\users\xxx\code\watson\watson\utils.py", line 254, in safe_save
shutil.move(tmpfp.name, path)
File "C:\Users\xxx\AppData\Local\miniforge3\lib\shutil.py", line 843, in move
copy_function(src, real_dst)
File "C:\Users\xxx\AppData\Local\miniforge3\lib\shutil.py", line 444, in copy2
copyfile(src, dst, follow_symlinks=follow_symlinks)
File "C:\Users\xxx\AppData\Local\miniforge3\lib\shutil.py", line 266, in copyfile
with open(dst, 'wb') as fdst:
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\xxx\\AppData\\Roaming\\watson\\config'

@thiborose
Copy link

I sidestepped this by creating the C:\Users\xxx\AppData\Roaming\watson directory, and creating an empty config file before running the command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants