canonical / jhack

Chock-full of Juju hackery.
Apache License 2.0
48 stars 23 forks source link

jhack crashes on machine without juju bootstrapped #95

Closed taurus-forever closed 10 months ago

taurus-forever commented 10 months ago

Hi,

jhack crashes if executed on machine without juju bootstrapped:

ubuntu@taurus-dev:~$ sudo snap install jhack --channel edge
jhack (edge) 0.3.19.1.1 from Pietro Pasotti (ppasotti) installed

ubuntu@taurus-dev:~$ jhack ffwd
Traceback (most recent call last):
  File "/snap/jhack/235/bin/jhack", line 8, in <module>
    sys.exit(main())
  File "/snap/jhack/235/lib/python3.8/site-packages/jhack/main.py", line 23, in main
    configure()
  File "/snap/jhack/235/lib/python3.8/site-packages/jhack/config.py", line 87, in configure
    test_file.write_text("kuckadoodle-foo")
  File "/usr/lib/python3.8/pathlib.py", line 1255, in write_text
    with self.open(mode='w', encoding=encoding, errors=errors) as f:
  File "/usr/lib/python3.8/pathlib.py", line 1222, in open
    return io.open(self, mode, buffering, encoding, errors, newline,
  File "/usr/lib/python3.8/pathlib.py", line 1078, in _opener
    return self._accessor.open(self, flags, mode)
FileNotFoundError: [Errno 2] No such file or directory: '/home/ubuntu/.local/share/juju/.__test_rw_jhack__.hacky'

ubuntu@taurus-dev:~$ snap list jhack,juju
Name   Version        Rev    Tracking     Publisher   Notes
jhack  0.3.19.1.1     235    latest/edge  ppasotti    -
juju   3.1.6-4a2434a  24210  3.1/edge     canonical✓  -

Sure, it is minor, but good to write reasonable error here, e.g. Juju not found, etc.

BTW, it is time to update stable track! ;-)

channels:
  latest/stable:    0.3.14     2023-03-13 (201) 85MB -
  latest/candidate: 0.3.14     2023-03-13 (201) 85MB -
  latest/beta:      0.3.18.3   2023-07-28 (225) 89MB -
  latest/edge:      0.3.19.1.1 2023-07-28 (235) 89MB -