Skip to content

(maint) Inject CommonProgramFiles env var #113

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

Conversation

Iristyle
Copy link
Contributor

  • Cygwin environments notably omit a number of important Windows
    environment variables including:

    APPDATA
    CommonProgramFiles
    CommonProgramFiles(x86)
    LOCALAPPDATA
    ProgramData
    ProgramFiles(x86)
    ProgramW6432
    PSModulePath

  • When using the ADODB.Connection COM object, the provider from
    the Connection String (in our case SQLOLEDB.1) is a ProgID
    that references another COM component for the implementation
    of connection library to SQL Server. Standard COM library
    resolution procedures apply when finding the DLL on disk to
    load. In the registry, the path to the InProcServer32 used
    for the library is listed as:

    %CommonProgramFiles%\System\Ole DB\sqloledb.dll

    Since the key is a REG_EXPAND_SZ, normal rules about env var
    expansion apply here.

    Interestingly, when running under a default Cygwin SSH session,
    since %CommonProgramFiles% is not captured in the environment,
    COM fails to load sqloledb.dll and the failure is propagated
    during the .Open("Provider=SQLOLEDB.1; ... ") call.

    Fix this issue by capturing the hosts %ProgramFiles% environment
    variable and appending "\Common Files" to it, which is how
    the pathing structure has always been.

    The solution here is a bit hacky. It would be better to
    launch a process that doesn't capture the Cygwin environment,
    echo the %CommonProgramFiles% environment variable and then
    inject that into our SSH session.

@Iristyle Iristyle force-pushed the fix/master/inject-CommonProgramFiles-env-var branch 3 times, most recently from b9a2b0f to 69dd837 Compare May 20, 2015 19:07
step "Emit CommonProgramFiles environment variable"
common_program_files = agent.get_env_var('ProgramFiles') + "\\Common Files"
agent.add_env_var('CommonProgramFiles', common_program_files)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a workaround until we can test this module under something other than Cygwin?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If so, then 👍. If the point of this is to keep feeding to the cygwin tax, let's not and instead invest in getting this working with non-cygwin templates.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a cygwin tax @ferventcoder,

procmon output

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMHO, we need a more generic solution to the missing env vars problem on Windows + Cygwin, but that's out of scope for now.

@ferventcoder
Copy link
Contributor

Also, I noticed this ticket is marked as maint - however I feel that it had quite a few hours of development put towards it, so let's create a JIRA ticket and add it to the sprint.

@Iristyle Iristyle force-pushed the fix/master/inject-CommonProgramFiles-env-var branch from 69dd837 to b5ca32e Compare May 20, 2015 22:00
 - Cygwin environments notably omit a number of important Windows
   environment variables including:

   APPDATA
   CommonProgramFiles
   CommonProgramFiles(x86)
   LOCALAPPDATA
   ProgramData
   ProgramFiles(x86)
   ProgramW6432
   PSModulePath

 - When using the ADODB.Connection COM object, the provider from
   the Connection String (in our case SQLOLEDB.1) is a ProgID
   that references another COM component for the implementation
   of connection library to SQL Server.  Standard COM library
   resolution procedures apply when finding the DLL on disk to
   load.  In the registry, the path to the InProcServer32 used
   for the library is listed as:

   %CommonProgramFiles%\System\Ole DB\sqloledb.dll

   Since the key is a REG_EXPAND_SZ, normal rules about env var
   expansion apply here.

   Interestingly, when running under a default Cygwin SSH session,
   since %CommonProgramFiles% is not captured in the environment,
   COM fails to load sqloledb.dll and the failure is propagated
   during the .Open("Provider=SQLOLEDB.1; ... ") call.

   Fix this issue by capturing the hosts %ProgramFiles% environment
   variable and appending "\Common Files" to it, which is how
   the pathing structure has always been.

   The solution here is a bit hacky.  It would be better to
   launch a process that doesn't capture the Cygwin environment,
   echo the %CommonProgramFiles% environment variable and then
   inject that into our SSH session.
@Iristyle Iristyle force-pushed the fix/master/inject-CommonProgramFiles-env-var branch from b5ca32e to c886193 Compare May 20, 2015 22:03
zreichert added a commit that referenced this pull request May 21, 2015
…Files-env-var

(maint) Inject CommonProgramFiles env var
@zreichert zreichert merged commit 6bc65f7 into puppetlabs:master May 21, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants