Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when value has $ #94

Closed
azliR opened this issue Mar 7, 2024 · 19 comments · Fixed by #95
Closed

Error when value has $ #94

azliR opened this issue Mar 7, 2024 · 19 comments · Fixed by #95
Assignees
Labels
bug Something isn't working enhancement New feature or request

Comments

@azliR
Copy link

azliR commented Mar 7, 2024

The output:

[SEVERE] envied_generator:envied on lib/configs/environment.dart:

Could not format because the source could not be parsed:

line 11, column 50 of .: Expected an identifier.
   ╷
11 │ static const String dbPassword = 'somestringwith$';
   │                                                  ^
   ╵
[INFO] Running build completed, took 62ms
[INFO] Caching finalized dependency graph completed, took 33ms
[SEVERE] Failed after 99ms

but when i change it to somestringwith\$, it worked.

@techouse
Copy link
Collaborator

techouse commented Mar 7, 2024

Hi @azliR

Can you please clarify if the value you have in your .env file contains a $ in it, i.e.

DB_PASSWORD=somestring$

and when you change it to

DB_PASSWORD=somestring\$

it worked?

@techouse techouse self-assigned this Mar 7, 2024
@techouse techouse added bug Something isn't working enhancement New feature or request labels Mar 7, 2024
@techouse
Copy link
Collaborator

techouse commented Mar 7, 2024

@azliR can you please test with this PR #95

dependency_overrides:
  envied:
    git:
      url: https://github.com/petercinibulk/envied
      ref: 83466c8679cdbbc135f1d9802410764cf283f6ed
      path: packages/envied/
  envied_generator:
    git:
      url: https://github.com/petercinibulk/envied
      ref: 83466c8679cdbbc135f1d9802410764cf283f6ed
      path: packages/envied_generator/

@azliR
Copy link
Author

azliR commented Mar 7, 2024

Hi @azliR

Can you please clarify if the value you have in your .env file contains a $ in it, i.e.

DB_PASSWORD=somestring$

and when you change it to

DB_PASSWORD=somestring\$

it worked?

Yess

@azliR
Copy link
Author

azliR commented Mar 7, 2024

@azliR can you please test with this PR #95

dependency_overrides:
  envied:
    git:
      url: https://github.com/petercinibulk/envied
      ref: 83466c8679cdbbc135f1d9802410764cf283f6ed
      path: packages/envied/
  envied_generator:
    git:
      url: https://github.com/petercinibulk/envied
      ref: 83466c8679cdbbc135f1d9802410764cf283f6ed
      path: packages/envied_generator/

Sure! Give me a minute

@azliR
Copy link
Author

azliR commented Mar 7, 2024

I don't know why it said success, but the env.g.dart is not generated.

@techouse
Copy link
Collaborator

techouse commented Mar 8, 2024

Did you follow the directions in the description of PR #95?

@azliR
Copy link
Author

azliR commented Mar 8, 2024

Yes, both with @EnviedField(rawString: true) and @Envied(rawStrings: true)

@techouse
Copy link
Collaborator

techouse commented Mar 8, 2024

What if you try using the branch as the ref, i.e.

dependency_overrides:
  envied:
    git:
      url: https://github.com/petercinibulk/envied
      ref: fix/issue-94-raw-strings
      path: packages/envied/
  envied_generator:
    git:
      url: https://github.com/petercinibulk/envied
      ref: fix/issue-94-raw-strings
      path: packages/envied_generator/

@techouse
Copy link
Collaborator

techouse commented Mar 9, 2024

I don't know why it said success, but the env.g.dart is not generated.

I think you might need to clean your build beforehand.

@azliR
Copy link
Author

azliR commented Mar 9, 2024

What if you try using the branch as the ref, i.e.

dependency_overrides:
  envied:
    git:
      url: https://github.com/petercinibulk/envied
      ref: fix/issue-94-raw-strings
      path: packages/envied/
  envied_generator:
    git:
      url: https://github.com/petercinibulk/envied
      ref: fix/issue-94-raw-strings
      path: packages/envied_generator/

I think you might need to clean your build beforehand.

Sorry, just got time to try again, I did those but sadly it still not generate anything

@techouse
Copy link
Collaborator

techouse commented Mar 9, 2024

Sorry, just got time to try again, I did those but sadly it still not generate anything

That doesn't make sense as all the PR does is add raw to the literalString call.

So just to confirm, you ran:

dart run build_runner clean
dart run build_runner build --delete-conflicting-outputs

correct?

Also, can you please clone PR #95 and try to do

cd envied/examples/envied_example
dart pub get
dart run build_runner clean
dart run build_runner build --delete-conflicting-outputs

Does it produce all the *.g.dart files?

@azliR
Copy link
Author

azliR commented Mar 9, 2024

Sorry, just got time to try again, I did those but sadly it still not generate anything

That doesn't make sense as all the PR does is add raw to the literalString call.

So just to confirm, you ran:

dart run build_runner clean
dart run build_runner build --delete-conflicting-outputs

correct?

Yess

Also, can you please clone PR #95 and try to do

cd envied/examples/envied_example
dart pub get
dart run build_runner clean
dart run build_runner build --delete-conflicting-outputs

Does it produce all the *.g.dart files?

Sure, in a minute

@azliR
Copy link
Author

azliR commented Mar 9, 2024

I tried #95 and it worked! I really don't know why it doesn't with my current project. Unfortunately I can't share the source code for my project. for you to try it.

@techouse
Copy link
Collaborator

techouse commented Mar 9, 2024

There might be something wrong with your setup. Check #90 and #89 and see if you have the same issue(s).

@techouse
Copy link
Collaborator

techouse commented Mar 9, 2024

Also, one thing to note is that at the moment any $foo will be interpolated as a bash var. I'm, looking into disabling that when a user specifies rawString.

@techouse
Copy link
Collaborator

techouse commented Mar 9, 2024

@azliR I have added 2 new annotations to #95

@Envied(intepolate: false)
class Env {
  static const String? foo;
}
@EnviedField(interpolate: false)
static const String? foo;

It's there to disable $BASH_VAR interpolation so that a string like foo$bar%baz won't have $bar interpolated.

It should be used in conjunction with rawString if you plan on using any chars that might cause exceptions.

@EnviedField(
  rawString: true,
  interpolate: false
)
static const String? testUnescapedString;

@nszenoti
Copy link

@techouse
cc: @azliR

Same issue happen with hash-tag (ie #)

Eg

DB_PASSWORD=somestring$abcd#random

Output :- "somestring$abcd"

Expected: "somestring$abcd#random"

@techouse
Copy link
Collaborator

techouse commented Mar 28, 2024

Not sure a # will be allowed like that, because it's probably treated as a comment.

You'll have to wrap your string in single quotes, i.e.

DB_PASSWORD='somestring$abcd#random'

Also, until #97 is released, please continue using the master branch.

@nszenoti
Copy link

@techouse

tried using single quote but it's not seems to be desirable solution.

Getting this
Bad state: Pattern matching error

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants