[▲ Vercel Community](/) · [Categories](/categories) · [Latest](/latest) · [Top](/top) · [Live](/live)

[Discussions](/c/community/4)

# Newline detection in addToGitIgnore

45 views · 1 like · 2 posts


Ben Ramey (@benramey-logos) · 2025-04-25 · ♥ 1

We've run into an issue when running `vercel env pull` where `.env*.local` is added to `.gitgnore` even when it's already in the file.

The problem seems to be in `addToGitIgnore` [here](https://github.com/vercel/vercel/blob/main/packages/cli/src/util/link/add-to-gitignore.ts#L13) where the `EOL` is determined.

In my case, I'm working on Windows (where `os.EOL` is `\r\n`) but our `.gitignore` has `\n` line-endings.  So, the line referenced above does not successfully split the `.gitignore` file lines and, thus, [when the check is performed](https://github.com/vercel/vercel/blob/main/packages/cli/src/util/link/add-to-gitignore.ts#L16) to see if `.env*.local` (or whatever is passed in) is already in the file, it fails and adds it again.

The solution seems to simply use `\n` in the `else` of the ternary on line 13.  Like this: https://github.com/vercel/vercel/compare/main...benramey-faithlife:vercel:fix-newline-detection-in-addToGitIgnore


Ben Ramey (@benramey-logos) · 2025-04-26

Looks like there is a [pull request](https://github.com/vercel/vercel/pull/12396) attempting to address this issue.  I feel like the solution proposed in that PR is overly complex, but perhaps it's addressing potential edge cases I'm not thinking of.