kylebebak / Requester

Powerful, modern HTTP/REST client built on top of the Requests library
https://kylebebak.github.io/Requester/
MIT License
307 stars 10 forks source link

Problems when installed as a `.sublime-package` file #1

Closed keith-hall closed 7 years ago

keith-hall commented 7 years ago

I saw this at https://github.com/wbond/package_control_channel/pull/6294 and was interested to try it. Unfortunately, there seems to be a few problems at the moment. (I like the descriptiveness of your PR on the PC channel btw :))

Summary

When Requester is installed via Package Control, trying to use the Requester: Show Tutorial item in the Command Palette throws lots of errors in the ST console instead of showing the tutorial.

Expected behavior

The functionality described in the readme would work, for example, the tutorial.

Actual behavior

Nothing happens (except the traceback) when trying to run the tutorial.

Traceback (most recent call last):
  File "C:\Program Files\Sublime Text 3\sublime_plugin.py", line 797, in run_
    return self.run()
  File "other_commands in C:\Users\Keith\AppData\Roaming\Sublime Text 3\Installed Packages\Requester.sublime-package", line 42, in run
  File "./python3.3/shutil.py", line 109, in copyfile
FileNotFoundError: [Errno 2] No such file or directory: 'C:\\Users\\Keith\\AppData\\Roaming\\Sublime Text 3\\Packages\\Requester\\docs\\_tutorial.md'

Steps to reproduce

  1. Open ST
  2. Open Command Palette
  3. Type PC: AR
  4. Select Package Control: Add Repository
  5. Paste in https://github.com/kylebebak/Requester and press Enter
  6. Open Command Palette
  7. Select Package Control: Install Package
  8. Type Requester
  9. Open Command Palette
  10. Type rtut and select Requester: Show Tutorial
  11. Notice nothing happens. Open the ST console and see the traceback

Tips

Maybe add a .no-sublime-package file to fix this problem, or ideally, find a way to make it work in a package :)

Environment

kylebebak commented 7 years ago

@keith-hall

Thanks for the detailed issue, I'm working on this right now.

Ok, it looks like everything is working except for the tutorial. If you use PackageResourceViewer to extract the Requester package and then run the tutorial, it works fine.

But before extracting the package, it raises an exception because it's trying to read a file from a directory that doesn't exist until the package is extracted...

I have an idea about how to fix this without using a .no-sublime-package file. Thanks again!

kylebebak commented 7 years ago

@keith-hall

Ok, I created a new release that fixes this bug, at least on my machine.

I would love to hear what you think of the package!

keith-hall commented 7 years ago

Thanks @kylebebak :) when I run the Show Tutorial command now, it opens 👍 but with an error:

---------------------------
Sublime Text
---------------------------
Error loading syntax file "Packages/MarkdownEditing/Markdown.tmLanguage": Unable to open Packages/MarkdownEditing/Markdown.tmLanguage
---------------------------
OK   
---------------------------

Maybe you should detect if the MarkdownEditing package is installed before setting the syntax? And set to the default one if not - it's been vastly improved recently but doesn't highlight code in fenced code blocks yet.

What platform are you testing on, out of interest? I'm getting an error when I follow the tutorial, and execute Requester: Run Requests from the Command Palette when my caret is on the url in the requests.get('https://jsonplaceholder.typicode.com/albums') line:

  File "D:\Software\Sublime Text 3\sublime_plugin.py", line 818, in run_
    return self.run(edit)
  File "common in C:\Users\Keith\AppData\Roaming\Sublime Text 3\Installed Packages\Requester.sublime-package", line 26, in run
  File "common in C:\Users\Keith\AppData\Roaming\Sublime Text 3\Installed Packages\Requester.sublime-package", line 43, in get_env
  File "<string>", line 4, in <module>
AttributeError: 'module' object has no attribute 'cookies'
kylebebak commented 7 years ago

@keith-hall

Thanks for continuing to look into this. I did some reading, and it looks like Sublime Text doesn't have a default Markdown syntax. So I'm checking if the user has MarkdownEditing installed, and if they do, I'm setting the syntax of the tutorial. If they don't, I'm leaving it as plain text.

I'm on OSX, build 3126. It looks like referencing requests.cookies is raising the AttributeError. This happened to me a few days ago, but the problem was resolved when I uninstalled and reinstalled Requester.

As far as I understand this shouldn't be an issue, because requests is a dependency of my package.

This, in theory, should mean that I can use import requests in Requester. And requests.cookies shouldn't raise an AttributeError. I'm not sure what's going on here.

Does running Package Control: Satisfy Dependencies make any difference? Does uninstalling and reinstalling Requester do anything?

keith-hall commented 7 years ago

After running Package Control: Satisfy Dependencies and restarting ST it's working :) sorry, I should have thought of that myself. I wonder why the restart is needed... Maybe it'd be a good idea to mention it in the install notes, what do you think?

I can assure you that ST has a default Markdown syntax, I have worked on it myself: https://github.com/sublimehq/Packages/blob/master/Markdown/Markdown.sublime-syntax

After having had a little play around, I can see that this package is super useful - thanks for taking the time to build it :) If you're interested, and I get time, I might like to submit a PR to get the syntax highlighting a bit smarter, and color the HTTP headers nicely etc :)

kylebebak commented 7 years ago

@keith-hall

Hey Keith,

It would definitely be a good idea to mention it, tomorrow I'm going to push a release with some nice changes and close this issue:

I would be very grateful if you wanted to improve syntax highlighting, the HTTP headers, or anything else that could use some work =)

keith-hall commented 7 years ago

Sounds great Kyle! :) I just noticed a small typo you could fix in the next release too, to make this package look even more professional ;) https://github.com/kylebebak/Requester/blob/6803912917cd1d633e520fd367b156c4348ad9c9/messages/install.txt#L6

Resquester

kylebebak commented 7 years ago

Oops =)

kylebebak commented 7 years ago

@keith-hall

I uploaded release 1.3.0 which includes the features in my previous comment.

There is information in the README, the tutorial, and the install message advising users to run Package Control: Satisfy Dependencies if nothing is working.

Also, the default Markdown syntax is used as a fallback if MardownEditing syntax isn't found. Neither of these syntaxes causes an error popup to appear if it's not present.

I'm going to close this issue, and let AlexKvazos the package is ready. Thanks a lot!