ZachMassia / PlatformIO-Mode

PlatformIO Integration for Emacs
GNU General Public License v3.0
68 stars 20 forks source link

Platformio can't see correct working directory #11

Closed vatrat closed 1 year ago

vatrat commented 6 years ago

This is related to #10. I am also using spacemacs. No matter what I try, I can't get platformio-mode to use the correct directory when building. It always uses ~/code, not ~/code/embedded/esp32/test/ (~/code/embedded/esp32/test/src/ is the current directory). I tried using cd to correct the directory of the main.cpp buffer but it had no effect. I then went to the PIO buffer and changed the directory, but it had no effect. I tried the line (add-to-list 'projectile-project-root-files "platformio.ini") in my .spacemacs, but it tells me Error in dotspacemacs/user-config: Symbol’s value as variable is void: projectile-project-root-files. I used describe-variable to look at default-directory and it told me this:

default-directory is a variable defined in ‘C source code’.
Its value is "/home/vatrat/code/embedded/esp32/test/src/"
Local in buffer main.cpp; global value is nil

  Automatically becomes permanently buffer-local when set.
  This variable is safe as a file local variable if its value
  satisfies the predicate ‘stringp’.

However, when I run C-c i b or C-c i u from the same file PIO shows

-*- mode: platformio-compilation; default-directory: "~/code/" -*-
PIOCompilation started at Mon Dec  4 19:16:17

platformio -f -c emacs run 
Error: Please setup environments in `platformio.ini` file

PIOCompilation exited abnormally with code 1 at Mon Dec  4 19:16:18
vatrat commented 6 years ago

This is coming quite a while later, but one workaround I've found is to create an empty .projectile file in the root directory. By using customize-group to look at the projectile variable, it seems that putting the add-to-list line in my .spacemacs file isn't working to change the variable. I'm not currently familiar enough with emacs to see why, probably something to do with loading order.

ZachMassia commented 6 years ago

Hi @vatrat

I apologize for the complete silence on this. I will have to go look into getting email notifications turned on for issues.

I will try to have a look at this in the next few days; In the meantime perhaps have a look at my Emacs config to see if you may have something set up different.

Some sections of interest:

pat1 commented 4 years ago

same problem for me: emacs-26.3 Fedora 31 PlatformIO, version 4.3.2a1 create an empty .projectile file in the root directory solve the problem

dantecatalfamo commented 3 years ago

I think this might be caused by projectile looking for a git repository. I've had a similar problem before where projectile wouldn't recognize my project until I ran git init in the root

ghost commented 2 years ago

For me also working with git init

ZachMassia commented 1 year ago

Better late than never, but seems like git init is the key here.