Giter Site home page Giter Site logo

ashald / envfile Goto Github PK

View Code? Open in Web Editor NEW
526.0 11.0 123.0 1.77 MB

EnvFile 3.x is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurations from one or multiple files.

License: MIT License

Java 100.00%
envfile yaml json jetbrains idea pycharm rubymine plugin

envfile's Introduction

EnvFile

Description

Env File is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurations from one or multiple files.

Supported Formats

All formats assume that both keys and values are strings.

Supported Platforms

Expand to see supported run configuration types. Italic means that run configuration is only available in paid version of the product.

PyCharm
  • App Engine server
  • Behave
  • Django server
  • Django tests
  • Lettuce
  • Pyramid server
  • Python
  • Python docs
    • Docutils task
    • Sphinx task
  • Python test
    • Unittests
    • Doctests
    • Nosetests
    • py.test
    • Attests
  • Tox
IDEA
  • Application
  • Arquillian JUnit
  • Arquillian TestNG
  • CloudBees Server
  • Cucumber Java
  • Gradle (requires "Enable Experimental Integrations")
  • GWT Configuration
  • Geronimo Server
    • Local
    • Remote
  • GlassFish Server
    • Local
    • Remote
  • Google AppEngine Dev Server
  • Grails
  • JAR Application
  • JBoss Server
    • Local
    • Remote
  • JSR45 Compatible Server
    • Local
    • Remote
  • Jetty Server
    • Local
    • Remote
  • JUnit
  • Kotlin
  • Kotlin script
  • Resin
    • Local
    • Remote
  • Spring Boot
  • Spring dmServer
    • Spring dmServer (Local)
    • Spring dmServer (Remote)
  • TestNG
  • TomEE Server
    • Local
    • Remote
  • TomCat Server
    • Local
    • Remote
  • WebLogic Server
    • Local
    • Remote
  • WebSphere Server
    • Local
    • Remote
RubyMine
  • Capistrano
  • Cucumber
  • Gem Command
  • IRB Console
  • RSpec
  • Rack
  • Rails
  • Rake
  • Ruby
  • Spork DRb
  • Test::Unit/Shoulda/Minitest
  • Zeus Server
GoLand
  • Go App Engine
  • Go Build
  • Go Test
Cursive (>=1.8.2)
  • Local Clojure REPL
  • Clojure Application
  • Leiningen

Installation

  • Using IDE built-in plugin system:

    • Preferences > Plugins > Browse repositories... > Search for "Env File" > Install Plugin
  • Manually:

    • Download the latest release and install it manually using Preferences > Plugins > Install plugin from disk...

Restart IDE.

Usage

  1. Add new Run/Debug configuration: + Add new configuration > ...
  2. Switch to EnvFile tab
  3. Select Enable EnvFile checkbox
  4. Select Substitute Environment Variables checkbox (if needed)
  5. Select Process JetBrains path macro references checkbox (if needed)
  6. Select Ignore missing files checkbox (if needed)
  7. Select Enable experimental integrations checkbox (if needed)
  8. Click on + to add a file
  9. Adjust order as needed
  10. Even variables defined within run configuration can be processed, ordered and substituted

Read from file

Caveats

Hidden files

Hidden files (starting with a dot) are not displayed in Finder on macOS by default. To toggle hidden files in the Open dialog, press COMMAND + SHIFT + .. Alternatively, one can either tweak macOS to show hidden files or select any file using standard Finder dialog and then manually edit path by double-clicking on the entry in the table.

Experimental Integrations

Not all run configurations available in IDEA-based IDEs are implemented similarly. Some of them differ significantly. In certain cases (so far, only Gradle has been confirmed) the implementation exposes interfaces to integrate the EnvFile UI but doesn't provide interfaces for it to actually make its work. Luckily, it was possible to make few assumptions about IDEA's internal implementation and make it work. Such integration is very fragile and it's not immediately clear if it will affect any existing integrations and when it will break. For that reason there is a special option to Enable Experimental Integrations that can be enabled when desired and should prevent other integrations from breaking.

Examples

.env

# This line is ignored since it's a comment
SECRET_KEY=hip-hip-env-files
VERSION=1.0

or

# This line is ignored since it's a comment
SECRET_KEY hip-hip-env-files
VERSION 1.0

JSON

{
    # JSON doesn't have comments but since JSON is subset of YAML
    # We parse it with YAML parser and therefore have comments
    # And even trialling commas in objects :)
    "SECRET_KEY": "hip-hip-env-files",
    "VERSION": "1.0", # All non-string literals should be enclosed in quotes; btw this is ignored too
}

YAML

# This line is ignored since it's a comment
SECRET_KEY: hip-hip-env-files
VERSION: "1.0" # All non-string literals should be enclosed in quotes; btw this is ignored too

Bash (workaround)

There was a number of requests to support extracting environment variables from bash scripts like:

export SECRET_KEY="hip-hip-env-files"
export VERSION="1.0"

The feasible way to do that is yet to be discovered (if any at all) so the plugin does not support that at the moment. On the other hand there is a simple workaround that can be used for the time being. The example bash script from above can be split into an .env file and a generic script that can be used to set environment variables on a command line:

.env

SECRET_KEY="hip-hip-env-files"
VERSION="1.0"

set-env.sh

while read -r line; do export $line; done < .env

usage

$ . set-env.sh
$ echo $VERSION
1.0

Variable Expansion

EnvFile also supports environment variable substitution. It's optional and disabled by default. Implementation is based on StringSubstitutor so it's the best reference for how it works.

Examples

Syntax is derived from Bash but is way more primitive:

A=${FOO}            # A=""        <- unknown variables replaced by empty strings
B=${FOO:-default}   # B="default" <- default values can be set as in Bash
C=${B}              # C="default" <- it's possible to refer to other variables that were previously evaluated
D=$${C}             # D="$${C}"   <- double dollar serves as an escape character
E=$C                $ E="$C"      <- curly brackets are required

Precedence

Environment variables are evaluated in the order they are defined in files. Files are evaluated in the order defined in EnvFile UI. Environment variables defined in run configuration can be ordered relatively to files. Order between environment variables defined in run configuration is not defined.

It is possible to refer to any environment variables that were evaluated previously - within same file or from other sources.

Path Macro Substitution

EnvFile can substitute JetBrains path macro references such as $PROJECT_DIR$ etc. It's optional and disabled by default. For details - see "Working with $PROJECT_DIR$ in plugin configuration options".

Further Development

  • Add more formats (upon requests)
  • Add support for other JetBrains products/plugins (upon requests)
  • Add more tests (¯\_(ツ)_/¯)

Building

EnvFile uses Gradle for building.

$ ./gradlew clean test build
  
  BUILD SUCCESSFUL in 22s
  59 actionable tasks: 59 executed
  
$ ls -1 build/distributions
  Env File-2.1.1-SNAPSHOT.zip

In order to open plugin's project in IDE, just open it as a Gradle project. Then use intelij:runId on the root of the project to launch an IDEA instance. You can set IDE env var for the run configuration pointing at IDE folder (IDE Folder/Content on macOS) to test plugin with different versions.

Feedback

Any feedback, bug reports and feature requests are highly appreciated!

Feel free to create an issue, contact me using Github or just drop me an email to the address specified in plugin.xml/idea-plugin/vendor@email.

License

Copyright (c) 2017 Borys Pierov. See the LICENSE file for license rights and limitations (MIT).

envfile's People

Contributors

andye2004 avatar ashald avatar bbaga avatar davidjfelix avatar dfa1 avatar jansorg avatar jpullar-orgvue avatar justinharshbarger avatar kelnor277 avatar koiuo avatar ledoyen avatar pilzm avatar savulchik avatar thomasgassmann avatar yoanthiebault avatar zalito12 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

envfile's Issues

Migration from old-style settings to the new ones?

I've updated plugin today and haven't noticed new EnvFile tab, so thought it's broken (I'm on PyCharm EAP build, so I've assumed things could break quite easily). Thanks to a picture in README.md, I've figured it all out, though.

However, "EnvFile" tab was empty, and my .env file was only mentioned as ENV_FILE_PATH=/full/path/to/.env and ENV_FILE_IS_ENABLED=true variables in the vanilla "Environment variables" section (which don't seem to have any effect with the new version).

Maybe it would be a good idea to automatically migrate those to a new-style configuration?

Default env file should be ~/.envrc

I would recommend going to a default .envrc file, as this became some kind of defacto standard for environment files, with more and more tools supporting it.

For example direnv uses it and it can even load the best file to use based on current folder. The tool would look for the file in current folder and its parents until it reaches user home directory. This allows users to share env files across multiple projects.

cannot set PYTHONPATH?

This plugin seems to work well setting our environment variables.

There is one var in particular, however, which doesn't seem to be set when we put it in the env file. That is PYTHONPATH.

My test was to place PYTHONPATH in the run config env vars and print out the var to console. This worked.

When I placed PYTHONPATH in the .env file and printed the var out to console, this did not work. However, other vars did.

JSON file in env var value not being parsed

I have an env var that I'm storing a JSON object in. It works in my bash_profile like this...

export JSON='{ "foo": "bar" }'

IntelliJ picks it up, everything works fine except.

However, when I try to add it into IntelliJ using EnvFile I get this error...

Illegal unquoted character ((CTRL-CHAR, code 10)): has to be escaped using backslash to be included in string value

Is this a known/expected issue with EnvFile? Will it ever support JSON as a value in an env var?

Thanks (really like EnvFile),
Tom

Remember last n files

Great plugin, enjoying using it so much!

One of the issues I come over is necessity so select same file multiple times when running different scripts. Is it possible to save recent used files and add them to the drop down menu (next to .env file and JSON/YAML file)?

Thank you.

Dereferencing variables in Run Config fields..

Created environment.env file, configured on EnvFile tab, now I'm trying to use variables in Run Config, I was banking on using variables like this because I have many run configs that share the same arguments, but the variable is not replaced; is this supported?

CONNECT_URL=tcp://myhost.com

env-plugin

Environment variables aren't loaded in IDEA

Hi,

First of all, thank you for this nice plugin !

I installed it but it didn't load the environment variables with IntelliJ IDEA Community Edition 2016.3.5. For information:

  • Here is the run configuration: settings
  • The .env file just contains FOO=BAR
  • System.getenv().containsKey("FOO") returns false

Could you please tell me if I missed something ?

Yoan

[Bug] Backslash is removed from env values

Given the following line in the *.env file:

TEST_VAR=value\1

the resulting environment variable set in the system is this:

TEST_VAR=value1

OS: Windows 10
Plugin version: 2.1.0

Add feature to automatically pick .env file(s) from project_root directory

Thanks for this awesome project, it solved a lot of issues with env management for me :).
I believe it would be awesome to add a feature (may be disabled by default) which when enabled make EnvFile to automatically load .env file(s) from project_root.
So that we enable this feature and we don't need to add .env files in run configuration for each project we just place the .env file in project_root and it will automatically be loaded.

Django Console stopped reading environment variables

i've been using the plugin successfully for some weeks.

Today, at some point, i couldn't use the Django Console because it was complaining about missing configurations (SECRET_KEY, for example) that should be available.

Traceback (most recent call last):
 [...]
    raise ImproperlyConfigured("The SECRET_KEY setting must not be empty.")
ImproperlyConfigured: The SECRET_KEY setting must not be empty.

The settings file selected for Django support reads the SECRET_KEY value from the environment ('SECRET_KEY': os.environ.get('SECRET_KEY')).

This had been working for months. i don't know why it stopped all of the sudden.

i also have the env file selected in "Build, Execution, Deployment > Console > Django Console". i tried unselecting "Read from file" and manually entereing the variables, but it still didn't work.

In "Languages & Frameworks > Django > Enable Django Support > Environment variables", i added the variables and it still didn't work.

The manage.py@Service worked just fine; it could find the variables (manually-entered only, i think), from "Languages & Frameworks > Django > Enable Django Support > Environment variables"

Uninstalling this plugin (and restarting PyCharm) immediately fixed the issue, in that the manually entered env variables were being applied in the Django Console.

Interestingly, after reinstalling the pluging and restarting, it was still working, and then after selecting the env file again, it was back to working as normal.

PyCharm 5.0.1

IntelliJ, and multiple files...

A bit of a two-fer, but could you add:

  1. Support for multiple files with an explicit load order -- last-one-wins on key conflicts.
  2. Ability to use this with IntelliJ and non-Python projects (in particular, for JVM-based projects of course).

Basically I have a scaffold of build tools using dotenv and want to be able to make use of the relevant files from IntelliJ.

Support for default values in .env

Would it be possible to support syntax of default values in .env files?
As in

DB_HOST=${DB_HOST:-127.0.0.1:3306}

This can prove very helpful for my usage pattern.

multiline support

I need to use variablesin .env whose values span multiple lines. Useful for e.g. ssl certifcates or - in my case - vcap setting of cloudfoundry. I definetly don't want to replace all the linebreaks of my 70-line cfg setting with \n and write it in one line.

Any support for that?

NullPointerException related to filename of .env

When using this plugin, i got a java.lang.NullPointerException, and after some fiddling around, it seemed to be related to the filename of the .env i was using: ".env.local". When i changed it to "dev.env", it worked fine.

Add support for NPM run config

Have used this plugin for quite a while now with most of my projects and I love it. Would it be possible to add support for npm run config?

[Bug] Plugin conflict with IDEA ScalaTest

If I create ScalaTest Run/Debug Configuration and enable EnvFile something went wrong. When I'm trying to run this configuration i've got error:

Error running 'IT-tests':
Unknown error

If I restart IDE - error disappears. If I change something in 'IT-tests' configuration - it appears again and Configuration Environment variables fills with .env file content (it didn't happen before as I remember)

IDE
IntelliJ IDEA 2017.3.2 (Ultimate Edition)
Build #IU-173.4127.27, built on December 25, 2017

JRE: 1.8.0_152-release-1024-b8 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.13.2

idea.log

2018-01-12 10:08:47,515 [ 316559]   INFO - s.CompilerReferenceServiceImpl - backward reference index reader is opened 
2018-01-12 10:08:47,653 [ 316697]   WARN - xecution.runners.ExecutionUtil - Execution error without description 
java.lang.UnsupportedOperationException
	at com.google.common.collect.ImmutableMap.clear(ImmutableMap.java:620)
	at net.ashald.envfile.platform.ui.EnvFileConfigurationEditor.patchEnvironmentVariables(EnvFileConfigurationEditor.java:122)
	at net.ashald.envfile.products.idea.IdeaRunConfigurationExtension.updateJavaParameters(IdeaRunConfigurationExtension.java:53)
	at org.jetbrains.plugins.scala.testingSupport.test.AbstractTestRunConfiguration$$anon$2.$anonfun$createJavaParameters$8(AbstractTestRunConfiguration.scala:442)
	at org.jetbrains.plugins.scala.testingSupport.test.AbstractTestRunConfiguration$$anon$2.$anonfun$createJavaParameters$8$adapted(AbstractTestRunConfiguration.scala:441)
	at scala.collection.IndexedSeqOptimized.foreach(IndexedSeqOptimized.scala:32)
	at scala.collection.IndexedSeqOptimized.foreach$(IndexedSeqOptimized.scala:29)
	at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:191)
	at org.jetbrains.plugins.scala.testingSupport.test.AbstractTestRunConfiguration$$anon$2.createJavaParameters(AbstractTestRunConfiguration.scala:441)
	at com.intellij.execution.configurations.JavaCommandLineState.getJavaParameters(JavaCommandLineState.java:33)
	at com.intellij.execution.impl.DefaultJavaProgramRunner.doExecute(DefaultJavaProgramRunner.java:90)
	at com.intellij.execution.runners.GenericProgramRunner$execute$$inlined$runProfileStarter$1.executeAsync(GenericProgramRunner.kt:69)
	at com.intellij.execution.runners.GenericProgramRunnerKt$startRunProfile$$inlined$runProfileStarter$1.executeAsync(GenericProgramRunner.kt:69)
	at com.intellij.execution.impl.ExecutionManagerKtImpl$startRunProfile$startRunnable$1.run(ExecutionManagerKtImpl.kt:75)
	at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:88)
	at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:74)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.a(LaterInvocator.java:424)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:407)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:762)
	at java.awt.EventQueue.access$500(EventQueue.java:98)
	at java.awt.EventQueue$3.run(EventQueue.java:715)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:732)
	at com.intellij.ide.IdeEventQueue.h(IdeEventQueue.java:822)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:650)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:366)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)
2018-01-12 10:08:48,245 [ 317289]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stdout]: Build process started. Classpath: /Applications/IntelliJ IDEA.app/Contents/lib/jps-launcher.jar:/Library/Java/JavaVirtualMachines/jdk1.8.0_92.jdk/Contents/Home/lib/tools.jar:/Applications/IntelliJ IDEA.app/Contents/lib/optimizedFileManager.jar 
2018-01-12 10:08:48,306 [ 317350]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". 
2018-01-12 10:08:48,306 [ 317350]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: Defaulting to no-operation (NOP) logger implementation 
2018-01-12 10:08:48,306 [ 317350]   INFO - j.compiler.server.BuildManager - BUILDER_PROCESS [stderr]: SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.

Enabled plugins
Database Tools and SQL
Env File
Git Integration
Scala
YAML

Allow remote env files

For remote debugging, one needs remote env files.

This would some additional plumbing so that the remote env could be sourced by the remote interpreter at load time.

java.lang.IllegalArgumentException: Malformed \uxxxx encoding.

Malformed \uxxxx encoding.
java.lang.IllegalArgumentException: Malformed \uxxxx encoding.
	at java.util.Properties.loadConvert(Properties.java:574)
	at java.util.Properties.load0(Properties.java:391)
	at java.util.Properties.load(Properties.java:341)
	at net.ashald.envfile.parsers.DotEnvFileParser.readFile(DotEnvFileParser.java:26)
	at net.ashald.envfile.AbstractEnvFileParser.process(AbstractEnvFileParser.java:19)
	at net.ashald.envfile.platform.EnvFileEntry.process(EnvFileEntry.java:66)
	at net.ashald.envfile.platform.ui.EnvFileConfigurationEditor.patchEnvironmentVariables(EnvFileConfigurationEditor.java:113)
	at net.ashald.envfile.products.pycharm.PyCharmRunConfigurationExtension.patchCommandLine(PyCharmRunConfigurationExtension.java:53)
	at net.ashald.envfile.products.pycharm.PyCharmRunConfigurationExtension.patchCommandLine(PyCharmRunConfigurationExtension.java:16)
	at com.intellij.execution.configuration.RunConfigurationExtensionsManager.patchCommandLine(RunConfigurationExtensionsManager.java:160)
	at com.jetbrains.python.run.PythonCommandLineState.startProcess(PythonCommandLineState.java:216)
	at com.jetbrains.python.run.PythonCommandLineState.execute(PythonCommandLineState.java:144)
	at com.jetbrains.python.run.PythonScriptCommandLineState.execute(PythonScriptCommandLineState.java:112)
	at com.jetbrains.python.run.PythonCommandLineState.execute(PythonCommandLineState.java:138)
	at com.jetbrains.python.debugger.PyDebugRunner.createSession(PyDebugRunner.java:136)
	at com.jetbrains.python.debugger.PyDebugRunner.doExecute(PyDebugRunner.java:164)
	at com.intellij.execution.runners.GenericProgramRunner$1.execute(GenericProgramRunner.java:40)
	at com.intellij.execution.RunProfileStarter.executeAsync(RunProfileStarter.java:43)
	at com.intellij.execution.impl.ExecutionManagerImpl.a(ExecutionManagerImpl.java:390)
	at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:86)
	at com.intellij.openapi.application.TransactionGuardImpl.a(TransactionGuardImpl.java:109)
	at com.intellij.openapi.application.TransactionGuardImpl.submitTransaction(TransactionGuardImpl.java:118)
	at com.intellij.openapi.application.TransactionGuard.submitTransaction(TransactionGuard.java:122)
	at com.intellij.execution.impl.ExecutionManagerImpl.a(ExecutionManagerImpl.java:447)
	at com.intellij.execution.impl.ExecutionManagerImpl.compileAndRun(ExecutionManagerImpl.java:304)
	at com.intellij.execution.impl.ExecutionManagerImpl.startRunProfile(ExecutionManagerImpl.java:447)
	at com.intellij.execution.runners.GenericProgramRunner.execute(GenericProgramRunner.java:37)
	at com.intellij.execution.runners.BaseProgramRunner.execute(BaseProgramRunner.java:61)
	at com.intellij.execution.runners.BaseProgramRunner.execute(BaseProgramRunner.java:50)
	at com.intellij.execution.ProgramRunnerUtil.executeConfiguration(ProgramRunnerUtil.java:118)
	at com.intellij.execution.impl.ExecutionManagerImpl.a(ExecutionManagerImpl.java:122)
	at com.intellij.execution.impl.ExecutionManagerImpl.access$300(ExecutionManagerImpl.java:69)
	at com.intellij.execution.impl.ExecutionManagerImpl$3.run(ExecutionManagerImpl.java:539)
	at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:223)
	at com.intellij.util.Alarm$Request.runSafely(Alarm.java:418)
	at com.intellij.util.Alarm$Request.access$700(Alarm.java:343)
	at com.intellij.util.Alarm$Request$1.run(Alarm.java:385)
	at com.intellij.openapi.application.TransactionGuardImpl$2.run(TransactionGuardImpl.java:303)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.a(LaterInvocator.java:410)
	at com.intellij.openapi.application.impl.LaterInvocator$FlushQueue.run(LaterInvocator.java:399)
	at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
	at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
	at java.awt.EventQueue.access$500(EventQueue.java:97)
	at java.awt.EventQueue$3.run(EventQueue.java:709)
	at java.awt.EventQueue$3.run(EventQueue.java:703)
	at java.security.AccessController.doPrivileged(Native Method)
	at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:80)
	at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
	at com.intellij.ide.IdeEventQueue.e(IdeEventQueue.java:827)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:655)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:365)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
	at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
	at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Adding my file as ZIP incase it's an encoding / UTF-8 BOM issue
14.10.25017.zip

Support request -- IDEA/Cursive Plugin, Clojure REPL run configurations

This is maybe an uncommon use case, but I use the cursive plugin for IDEA which adds Clojure support and adds a couple new run configuration types. Would be great to be able to use EnvFile with those.

Pic of the configs attached. I'd be open to adding this myself with some guidance if you have time to write a little how-to 😄

image

Add .env files by text input instead of file selection

Classic .env file is hidden in UNIX systems (it starts with a .). I'd like to be able to easily write the path to the .env file without going through the FS.
Also, it should be clear also whether it's possible to use variables like $PROJECT_DIR$ in the path.

[feature request] directly support envdir format

envdir is another format for storing environment variables. the format looks like:

$ tree envs
envs
├── local
│   ├── DATADOG_API_KEY
│   ├── PYTHONPATH
│   └── STAGE
└── prod
    ├── PYTHONPATH
    └── STAGE

2 directories, 5 files

which can then be used in programs like:

envdir envs/local python app.py

right now I convert the envs/local folder into a .env file for use with this plugin but it would be great if the plugin could read the folder directly!

Use variables in env file

Hi,

It is possible has default variables in env file?

For instance:
HOST="x"
URL_A="${HOST}/cats"
URL_B="${HOST}/dogs"

Best regards

PYTHONPATH cannot bet set

The PYTHONPATH specified in the .env file seems to be overridden by PyCharm. Even with a very simple .env file like

PYTHONPATH=xyz

and unchecking "Add content/source roots to PYTHONPATH", the PYTHONPATH ends up being taken from the bash in which PyCharm was started.
Any other key, like

PATH=xyz

is working.

I was verifying this by printing os.environ.

Can't manually enter file paths

In 1.0.1, you could manually type in the path to the env file, but in 2.0.0 it requires a file dialog. However, in OSX's default file dialog, there's no way to select hidden files, and all dot-prefixed files are hidden, including .env.

This means I had to downgrade to 1.0.1 in order to select my .env files.

Feature: support hinting from .env.example files

A lot of projects that have .env files use .env.example as the example file, rather than provide an actual .env.

It would be cool if this plugin supported reading .env.example files, using them to generate suggestions when editing .env files.

Get env from a bash script

Is it possible to get env from Bash script? Basically equivalent to running source my_env.sh. Presumably, only variables that are export-ed should be used.

my_env.sh:

#!/usr/bin/env bash

export DJANGO_SETTINGS_MODULE=myproject.settings

if [ -f something/somewhere ]; then
    export $THAT_THING_IS=there
fi

# etc...

Support EnvFile in Python Console and for manage.py

There are two other places besides run configurations where you might need your .env file read.

Settings > Languages & Frameworks > Django > Manage.py tasks > Environment variables
Settings > Build, Execution, Deployment > Console > Django Console > Environment variables

If .env file isn't supported here, I have to manually copy all required values from .env to each of these places.

`export key=value` support

Hi there!

I've got a project that dynamically creates env files in the format

export FOO=bar
export ABC=onetwothree

To use this plugin, I Currently just open the file and replace 'export ' with '' - this is a little bit of a slowdown because the env file ends up changing, and I have to maintain a copy somehow outside of source control.

Is it possible for this project to selectively recognize if a line says 'export XX' and just drop 'export ' for importing variables? In all I imagine it'd be the right thing to do :)

broken in PyCharm 2017.2.1

i had been using the plugin successfully in several versions of PyCharm, up to 2017.1.2, But when i updated to 2017.2.1, the environment variables are no longer applying, which breaks my run configurations. Traceback just indicates missing environment variables. New configurations aren't working, either. i do have "Enable EnvFile" checked and an .env file selected in all cases.

IDE Fatal Error: NullPointerException

PyCharm 2016.1.4 reported a fatal error. The notice came when i opened a second IDE window, but i don't now if that was when it occurred, or if that was when i was notified: Exception in plugin Env File. Today at 9:19 AM. Occurred 2 times since the last clear. Unread.

This is all the context i have, unfortunately.

null
java.lang.NullPointerException
    at net.ashald.envfile.PyEnvFileRunConfigurationExtension.patchCommandLine(PyEnvFileRunConfigurationExtension.java:104)
    at net.ashald.envfile.PyEnvFileRunConfigurationExtension.patchCommandLine(PyEnvFileRunConfigurationExtension.java:24)
    at com.intellij.execution.configuration.RunConfigurationExtensionsManager.patchCommandLine(RunConfigurationExtensionsManager.java:160)
    at com.jetbrains.python.run.PythonCommandLineState.startProcess(PythonCommandLineState.java:190)
    at com.jetbrains.django.run.DjangoServerRunCommandLineState.startProcess(DjangoServerRunCommandLineState.java:206)
    at com.jetbrains.python.run.PythonCommandLineState.execute(PythonCommandLineState.java:131)
    at com.jetbrains.python.run.PythonRunner.doExecute(PythonRunner.java:51)
    at com.intellij.execution.runners.GenericProgramRunner$1.execute(GenericProgramRunner.java:43)
    at com.intellij.execution.impl.ExecutionManagerImpl$5.run(ExecutionManagerImpl.java:389)
    at com.intellij.execution.impl.ExecutionManagerImpl.compileAndRun(ExecutionManagerImpl.java:291)
    at com.intellij.execution.impl.ExecutionManagerImpl.startRunProfile(ExecutionManagerImpl.java:432)
    at com.intellij.execution.runners.GenericProgramRunner.execute(GenericProgramRunner.java:40)
    at com.intellij.execution.runners.BaseProgramRunner.execute(BaseProgramRunner.java:61)
    at com.intellij.execution.runners.GenericProgramRunner.execute(GenericProgramRunner.java:31)
    at com.intellij.execution.runners.BaseProgramRunner.execute(BaseProgramRunner.java:50)
    at com.intellij.execution.runners.GenericProgramRunner.execute(GenericProgramRunner.java:31)
    at com.intellij.execution.ProgramRunnerUtil.executeConfiguration(ProgramRunnerUtil.java:121)
    at com.intellij.execution.impl.ExecutionManagerImpl.a(ExecutionManagerImpl.java:116)
    at com.intellij.execution.impl.ExecutionManagerImpl.access$400(ExecutionManagerImpl.java:67)
    at com.intellij.execution.impl.ExecutionManagerImpl$7.run(ExecutionManagerImpl.java:516)
    at com.intellij.util.concurrency.QueueProcessor.runSafely(QueueProcessor.java:238)
    at com.intellij.util.Alarm$Request$1.run(Alarm.java:378)
    at com.intellij.util.Alarm$Request.run(Alarm.java:398)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at com.intellij.util.concurrency.SchedulingWrapper$MyScheduledFutureTask.run(SchedulingWrapper.java:227)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:756)
    at java.awt.EventQueue.access$500(EventQueue.java:97)
    at java.awt.EventQueue$3.run(EventQueue.java:709)
    at java.awt.EventQueue$3.run(EventQueue.java:703)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:726)
    at com.intellij.ide.IdeEventQueue.g(IdeEventQueue.java:857)
    at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:658)
    at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:386)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

EnvFile tab not appearing

Any suggestions on what to do if I'm not seeing the EnvFile tab in a new debug configuration after a reboot?

EDIT: to clarify I'm not seeing this in the Docker configurations, but I am seeing them in others

Add possibility to append to an existing variable

For an .env script like

PATH=/my/path:${PATH}

the plugin should prepend the current PATH with /my/path. Thus, if PATH=/another/path, the environment should result in PATH=/my/path:/another/path. Currently, PATH ends up being /my/path:${PATH}

go support

It'd be nice to get some support for golang, seems to be used somewhat pervasively. Thanks!

Pycharms can't get an env var?

I have an .env file that has an environment var pointing to a file location, pycharm with the ENV plugin cannot find it still despite following the README.

run configuration not finding env vars

This happened after i updated the plugin to 2.0. i have a .env file enabled and selected in the "EnvFile" tab, per instructions. When i run the configuration, no env vars have been applied. For the moment, i'm manually adding env vars the old way, to get by. Let me know if there's any further information which would be helpful.

PyCharm 2016.3.2 build 163.10154.50

Python Console Support

The Python Console in PyCharm can also have environment variables set. Is it possible to also support the Python Console loading variables from .env files on load?

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.