Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

getPaths() does not return Project Path #13860

Closed
MggMuggins opened this issue Feb 21, 2017 · 8 comments
Closed

getPaths() does not return Project Path #13860

MggMuggins opened this issue Feb 21, 2017 · 8 comments

Comments

@MggMuggins
Copy link

MggMuggins commented Feb 21, 2017

Prerequisites

I did not do this in safe mode, since I don't know of anything that prints the project path without an addon of some kind.
I read through the FAQ's and Debugging guide.
This is for a package that I am helping to maintain.

Description

The getPaths() method from the projects API is not functioning on Ubuntu 16.04. I am trying to extend an extension that does some things with project paths, and I've narrowed my troubles down to this method. I've hacked the extension that I'm working on so that when I run an atom command, it executes this line of bash script (This is actually a bit of coffee):
"gnome-terminal -e \"bash -ic \'echo #{atom.project.getPaths().shift()} && read -s -n 1 line\'\""
It's a little complicated, with a number of escape sequences, so I'll explain it here.
The gnome-terminal command runs all of the following using the -e option (this also works with xterm, although I've set my personal (and hacked) copy to gnome, since I prefer it).
bash is run so that the terminal actually shows up, rather than just running without opening a gui at all. This corresponds to the read statement at the end (see below)
The echo bit is just the bit that I hacked so that it would print the string it's supposed to be cd'ing to instead of trying, failing, and closing. Eventually it will cd to that path, and then execute something in there, but that isn't particularly relevant.
read (and all of it's args) is so that the terminal stays open so that you can see the output.

This all works great, I can see the output of getPaths() just fine. The problem is the output itself: undefined. Removing the .shift() property makes the method return nothing at all. I'm wondering if anyone else is having this problem (all platforms, I'm curious), and wondering why I'm having this issue (I am restarting atom every time I edit the file...).

Steps to Reproduce

  1. Create a package that executes that bit of coffee when you run a certain atom command.
  2. Run the command in atom. Ideally, you'll end up with a terminal with the output to your current project directory.

Expected behavior: I want it to spit out the project I'm currently working in.

Actual behavior: It prints undefined

Reproduces how often: 100% of the time this is the case. I am led to believe that this is not the case on other platforms.

Versions

atom --version:
Atom : 1.14.2
Electron: 1.3.13
Chrome : 52.0.2743.82
Node : 6.5.0
apm --version:
apm 1.15.3
npm 3.10.5
node 4.4.5 x64
python 2.7.11+
git 2.7.4

Like I mentioned before, I'm running a release version of Ubuntu Linux 16.04 LTS 64 bit. Let me know if you need any more info.

@MggMuggins
Copy link
Author

I would like to know if my report is being ignored because I haven't done any of the prerequisite stuff, or simply because no one knows what to say. I would not be able to reproduce the problem in safe mode, since the very nature of the problem is something safe mode would prevent happening, and I read over the debugging guide and FAQ's. There was some interesting stuff in there, but nothing I needed.

@50Wliu
Copy link
Contributor

50Wliu commented Feb 25, 2017

Sorry. We get a lot of issues, and it's hard to keep up. If the prerequisites don't apply, it would help if you included a message stating that, and why next time.

I am unable to use the code snippet you provided, since I'm on Windows, but just logging out atom.project.getPaths().shift() in the developer tools appears to work for me (returning "C:\Users\user\Documents\GitHub\about"). Does that work for you?

@MggMuggins
Copy link
Author

MggMuggins commented Feb 25, 2017

My method for seeing the output of that method is a little roundabout, so I'll try that.
Thanks for responding, I appreciate that, and I understand, I work with bug reports too for other software.

@MggMuggins
Copy link
Author

MggMuggins commented Feb 25, 2017

I hacked the init script to print what the method returns after the editor is saved. It worked, which seems really weird. Let me work on my tool for a bit and get back to you.

@MggMuggins
Copy link
Author

MggMuggins commented Feb 25, 2017

Right, so the init script printing that on editor save worked like a charm. However, I hacked the addon so that the path variable (which I set to the output of that method call) is printed when I run the command. I got undefined. The code (more or less) is in https://github.com/ysgard/d-struct/blob/master/lib/d-struct.coffee. I'm wondering why the method works in one place but not in the other.

@50Wliu
Copy link
Contributor

50Wliu commented Feb 25, 2017

Ok, looking at your code, it looks like you instantiate paths, but then never touch it again. Meaning that if the value of atom.project.getPaths() changes, it won't be reflected in the paths variable.

Since this is starting to look like a code issue, would you mind creating a topic on Discuss, the official Atom and Electron message board instead? We should be able to help you better there.

@50Wliu 50Wliu closed this as completed Feb 25, 2017
@MggMuggins
Copy link
Author

That makes sense. However, I don't think this is the case. The version of that file that I'm running is echoing the direct result of that method, so I don't think it's a programming error, even if that will be an issue. I can fix that later. My topic on the forum: https://discuss.atom.io/t/getpaths-issues/39996

@lock
Copy link

lock bot commented Apr 2, 2018

This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!

@lock lock bot locked and limited conversation to collaborators Apr 2, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants