# File access with mongrel running as windows service

**URL:** <https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502>\
**Category:** Mongrel\
**Created:** [November 7, 2007, 3:01pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502 "2007-11-07T15:01:45Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [November 7, 2007, 3:01pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/1 "2007-11-07T15:01:45Z")

</div>

i have an archive of documents (word, excel, jpeg, png, gif…)  
residing on a network share that is accessed via send\_file.

when running mongrel on the command line the files are properly  
delivered.  
with mongrel running as a service they don’t.

now normally i would think that should be fixable by configuring the  
service to run under a user that can read the files…

but i’ve already tried that without success.

running the service as system or administrator or the user i’m using  
for development (the same user i run the mongrel on command line) does  
_NOT_ help. so i can’t figure out how to get this to work.

development or production mode also doesn’t make a difference.

from what i’ve seen so far this generally applies to any File IO access.

could this be a bug in the mongrel service implementation?

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [November 7, 2007, 3:50pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/2 "2007-11-07T15:50:23Z")

</div>

On Nov 7, 2007 3:01 PM, gmail [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> i have an archive of documents (word, excel, jpeg, png, gif…)  
> residing on a network share that is accessed via send\_file.
> 
> when running mongrel on the command line the files are properly  
> delivered.  
> with mongrel running as a service they don’t.

Try running “net use” inside the process to see if the network share is  
mounted at all. This sounds like the typical Windows/web problem where  
the  
operator assumes that everybody sees the same shares that she sees in  
her  
session. In reality, network shares are mounted per login session. Two  
users can be logged in on the the same Windows server and have different  
shares available on Z:, which is clever, but also sort of confusing.  
What  
is even more confusing is that you may be logged on as “user1” and have  
something mapped to Z:, but the service running as user1 has nothing on  
Z: â€“  
it needs to create its own mappings.

Let us know if this helps.

/David

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [November 7, 2007, 4:13pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/3 "2007-11-07T16:13:17Z")

</div>

yes that helped!

i just needed to switch the drive letter with the UNC path 🙂

thanks for pointing that out.  
years of using windows but never thought it worked that way

Am 07.11.2007 um 15:48 schrieb David V.:

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [November 7, 2007, 4:29pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/4 "2007-11-07T16:29:05Z")

</div>

sorry that wasn’t posted “anonymously” on purpose.  
i just set up my gmail account with imap in apple mail last night and  
didn’t even noticed it put gmail in the sender name. until i sent the  
reply.

Am 07.11.2007 um 15:48 schrieb David V.:

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [November 7, 2007, 4:23pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/5 "2007-11-07T16:23:13Z")

</div>

yes that helped!

i just needed to switch the drive letter with the UNC path 🙂

thanks for pointing that out.  
years of using windows but never thought it worked that way

Am 07.11.2007 um 15:48 schrieb David V.:

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [August 17, 2010, 3:54pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/6 "2010-08-17T15:54:12Z")

</div>

David V. wrote:

> On Nov 7, 2007 3:01 PM, gmail [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > i have an archive of documents (word, excel, jpeg, png, gif…)  
> > residing on a network share that is accessed via send\_file.
> > 
> > when running mongrel on the command line the files are properly  
> > delivered.  
> > with mongrel running as a service they don’t.
> 
> Try running “net use” inside the process to see if the network share is  
> mounted at all. This sounds like the typical Windows/web problem where  
> the  
> operator assumes that everybody sees the same shares that she sees in  
> her  
> session. In reality, network shares are mounted per login session. Two  
> users can be logged in on the the same Windows server and have different  
> shares available on Z:, which is clever, but also sort of confusing.  
> What  
> is even more confusing is that you may be logged on as “user1” and have  
> something mapped to Z:, but the service running as user1 has nothing on  
> Z: â€“  
> it needs to create its own mappings.
> 
> Let us know if this helps.
> 
> /David

David could you explain it more i think i have same sort of problem  
what i am doing is.  
i created a web application using instant rails,i having rails  
2.2.2,mysql database,mongrel running as a server,  
i used mysql database to store the different property of files and i am  
plcing actual file(phsical file) on samba server.now i run my it as  
application ,everthing is fine but soon i run my application as windows  
service i am getting this problem

No such file or directory - Z:/streams/Texture.bmp  
Z: is drive letter  
here i am trying to upload Texture.bmp file to samba means to Z:/streams  
any help …

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [August 17, 2010, 4:08pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/7 "2010-08-17T16:08:41Z")

</div>

Luis L. wrote:

> On Tue, Aug 17, 2010 at 10:54 AM, Amit T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > No such file or directory - Z:/streams/Texture.bmp  
> > Z: is drive letter  
> > here i am trying to upload Texture.bmp file to samba means to Z:/streams  
> > any help …
> 
> Unless you’re running the mongrel service as the same user, the mapped  
> network drives are not available.
> 
> ## Either you use the full network path (\SERVER\PATH) or you run the service as the user that defines the mapped network drives.
> 
> ## Luis L. AREA 17
> 
> Perfection in design is achieved not when there is nothing more to add,  
> but rather when there is nothing more to take away.  
> Antoine de Saint-Exupé²¹

Luis  
i tried to set full network path  
but not successed and how do i run the service under the user that  
defines the mapped network drives.

> –

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [August 17, 2010, 4:25pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/8 "2010-08-17T16:25:42Z")

</div>

On Tue, Aug 17, 2010 at 11:08 AM, Amit T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Luis  
> i tried to set full network path  
> but not successed and how do i run the service under the user that  
> defines the mapped network drives.

You will need to access the Services definition and under properties  
select Run as user. You will need to provide the password too. (all  
this under administrative tools, things may vary between windows  
versions).

## – Luis L. AREA 17

Perfection in design is achieved not when there is nothing more to add,  
but rather when there is nothing more to take away.  
Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [August 17, 2010, 5:08pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/9 "2010-08-17T17:08:15Z")

</div>

Luis L. wrote:

> On Tue, Aug 17, 2010 at 11:08 AM, Amit T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > Luis  
> > i tried to set full network path  
> > but not successed and how do i run the service under the user that  
> > defines the mapped network drives.
> 
> You will need to access the Services definition and under properties  
> select Run as user. You will need to provide the password too. (all  
> this under administrative tools, things may vary between windows  
> versions).
> 
> ## – Luis L. AREA 17
> 
> Perfection in design is achieved not when there is nothing more to add,  
> but rather when there is nothing more to take away.  
> Antoine de Saint-Exupé²¹

r u saying i ahve to run my service under netwrok service and i would  
like to konw how i run my service under netwrok service??

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [August 17, 2010, 4:03pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/10 "2010-08-17T16:03:27Z")

</div>

On Tue, Aug 17, 2010 at 10:54 AM, Amit T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> No such file or directory - Z:/streams/Texture.bmp  
> Z: is drive letter  
> here i am trying to upload Texture.bmp file to samba means to Z:/streams  
> any help …

Unless you’re running the mongrel service as the same user, the mapped  
network drives are not available.

## Either you use the full network path (\SERVER\PATH) or you run the service as the user that defines the mapped network drives.

## Luis L. AREA 17

Perfection in design is achieved not when there is nothing more to add,  
but rather when there is nothing more to take away.  
Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [August 17, 2010, 5:27pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/11 "2010-08-17T17:27:11Z")

</div>

On Tue, Aug 17, 2010 at 12:08 PM, Amit T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> r u saying i ahve to run my service under netwrok service and i would  
> like to konw how i run my service under netwrok service??

No, I’m saying that you need to run your service under a user account  
that defines those mapped network drives. Since network mappings (Z:,  
W:, etc) are dependent of the user, needs to be run as that particular  
user.

You need to change those settings for that particular service under  
the “Services” manager in Administrative Tools (control panel).

## – Luis L. AREA 17

Perfection in design is achieved not when there is nothing more to add,  
but rather when there is nothing more to take away.  
Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [August 18, 2010, 2:47pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/12 "2010-08-18T14:47:23Z")

</div>

Luis L. wrote:

> On Tue, Aug 17, 2010 at 12:08 PM, Amit T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > r u saying i ahve to run my service under netwrok service and i would  
> > like ?to konw how i run my service under netwrok service??
> 
> No, I’m saying that you need to run your service under a user account  
> that defines those mapped network drives. Since network mappings (Z:,  
> W:, etc) are dependent of the user, needs to be run as that particular  
> user.
> 
> You need to change those settings for that particular service under  
> the “Services” manager in Administrative Tools (control panel).
> 
> ## – Luis L. AREA 17
> 
> Perfection in design is achieved not when there is nothing more to add,  
> but rather when there is nothing more to take away.  
> Antoine de Saint-Exupé²¹

LUIS  
i am not getting error like  
Permission denied - //Z/:streams/al00\_96000.aac  
what should i do and i am also running service as a particular user

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [August 18, 2010, 7:04pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/13 "2010-08-18T19:04:41Z")

</div>

On Wed, Aug 18, 2010 at 9:47 AM, Amit T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> LUIS  
> i am not getting error like  
> Permission denied - //Z/:streams/al00\_96000.aac  
> what should i do and i am also running service as a particular user

I’m having problems understanding your english.

Mapped network drives do not start with //, they are normal network  
letters:

C:\Users\Luis\>net view  
Server Name Remark

* * *

\KEORE

C:\Users\Luis\>net view \KEORE  
Shared resources at \KEORE

## Share name Type Used as Comment

Users Disk

C:\Users\Luis\>net use \* \KEORE\Users  
Drive Z: is now connected to \KEORE\Users.

The command completed successfully.

C:\Users\Luis\>irb  
irb(main):001:0\> require ‘fileutils’  
=\> true  
irb(main):002:0\> FileUtils.touch “Z://foo.txt”  
Errno::EACCES: Permission denied - Z://foo.txt  
from  
C:/Users/Luis/Tools/Ruby/ruby-1.8.7-p302-i386-mingw32/lib/ruby/1.8/fileutils.rb:1034:in  
`initialize' from C:/Users/Luis/Tools/Ruby/ruby-1.8.7-p302-i386-mingw32/lib/ruby/1.8/fileutils.rb:1034:in `open’  
from  
C:/Users/Luis/Tools/Ruby/ruby-1.8.7-p302-i386-mingw32/lib/ruby/1.8/fileutils.rb:1034:in  
`touch' from C:/Users/Luis/Tools/Ruby/ruby-1.8.7-p302-i386-mingw32/lib/ruby/1.8/fileutils.rb:1028:in `each’  
from  
C:/Users/Luis/Tools/Ruby/ruby-1.8.7-p302-i386-mingw32/lib/ruby/1.8/fileutils.rb:1028:in  
`touch’  
from (irb):2

It is clear I don’t have permission to do that, but:

irb(main):003:0\> FileUtils.touch “Z://Luis/foo.txt”  
=\> [“Z://Luis/foo.txt”]

I do.

Also:

irb(main):004:0\> FileUtils.touch “//Z://Luis/bar.txt”  
Errno::ENOENT: No such file or directory - //Z://Luis/bar.txt  
from  
C:/Users/Luis/Tools/Ruby/ruby-1.8.7-p302-i386-mingw32/lib/ruby/1.8/fileutils.rb:1034:in  
`initialize' from C:/Users/Luis/Tools/Ruby/ruby-1.8.7-p302-i386-mingw32/lib/ruby/1.8/fileutils.rb:1034:in `open’  
from  
C:/Users/Luis/Tools/Ruby/ruby-1.8.7-p302-i386-mingw32/lib/ruby/1.8/fileutils.rb:1034:in  
`touch' from C:/Users/Luis/Tools/Ruby/ruby-1.8.7-p302-i386-mingw32/lib/ruby/1.8/fileutils.rb:1028:in `each’  
from  
C:/Users/Luis/Tools/Ruby/ruby-1.8.7-p302-i386-mingw32/lib/ruby/1.8/fileutils.rb:1028:in  
`touch’  
from (irb):4

it is clear that // should not prepend the drive letter, but instead:

irb(main):005:0\> FileUtils.touch “//KEORE/Users/Luis/bar.txt”  
=\> [“//KEORE/Users/Luis/bar.txt”]

## I hope this explains a bit better what I’m talking about.

## Luis L. AREA 17

Perfection in design is achieved not when there is nothing more to add,  
but rather when there is nothing more to take away.  
Antoine de Saint-Exupéry

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [August 20, 2010, 3:31pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/14 "2010-08-20T15:31:10Z")

</div>

Luis I tried to upload a file of size 324mb but something strange  
happened  
i’m able to upload the file but still i’m getting error  
Invalid argument -  
[//192.122.227.53/Smar/streams2/D1\_monsters\_3\_720x480\_422i\_SP\_5Mbps\_30fps\_657frames.yuv](https://192.122.227.53/Smar/streams2/D1_monsters_3_720x480_422i_SP_5Mbps_30fps_657frames.yuv)  
but when i checked the location([//192.122.227.53/Smar/streams2](https://192.122.227.53/Smar/streams2)) file was  
there  
what could be the reason ??

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [August 20, 2010, 2:12pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/15 "2010-08-20T14:12:03Z")

</div>

Thanks my friend…  
i am able to figure out my problem …

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [August 27, 2010, 3:46pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/16 "2010-08-27T15:46:10Z")

</div>

Luis L. wrote:

> On Fri, Aug 20, 2010 at 10:31 AM, Amit T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > Luis I tried to upload a file of size 324mb but something strange  
> > happened  
> > i’m able to upload the file but still i’m getting error  
> > ?Invalid argument -  
> > [//192.122.227.53/Smar/streams2/D1\_monsters\_3\_720x480\_422i\_SP\_5Mbps\_30fps\_657frames.yuv](https://192.122.227.53/Smar/streams2/D1_monsters_3_720x480_422i_SP_5Mbps_30fps_657frames.yuv)  
> > but when i checked the location([//192.122.227.53/Smar/streams2](https://192.122.227.53/Smar/streams2)) file was  
> > there  
> > what could be the reason ??
> 
> I have no idea where are you receiving the ‘invalid argument’ error.
> 
> It is extrematelly important than when you report an error, provide  
> enough details and precision about it, more precisely, the full error  
> messages and backtraces.
> 
> We can’t replicate or provide you help if you skim it and provide  
> vague information.
> 
> ## Help us help you.
> 
> ## Luis L. AREA 17
> 
> Perfection in design is achieved not when there is nothing more to add,  
> but rather when there is nothing more to take away.  
> Antoine de Saint-Exupé²¹

i don’t know how to ask this question because am new to  
rails.  
but i want to know to is which part of code sumit\_tag will take you  
means  
after execution of sumit\_tag where control of programme goes??

---

<div class="post-metadata">

**Author:** ![neongrau](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/34f0e0/32.png) [@neongrau](https://www.ruby-forum.com/u/neongrau)\
**Post date:** [August 20, 2010, 4:27pm UTC](https://www.ruby-forum.com/t/file-access-with-mongrel-running-as-windows-service/119502/17 "2010-08-20T16:27:30Z")

</div>

On Fri, Aug 20, 2010 at 10:31 AM, Amit T. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Luis I tried to upload a file of size 324mb but something strange  
> happened  
> i’m able to upload the file but still i’m getting error  
> Invalid argument -  
> [//192.122.227.53/Smar/streams2/D1\_monsters\_3\_720x480\_422i\_SP\_5Mbps\_30fps\_657frames.yuv](https://192.122.227.53/Smar/streams2/D1_monsters_3_720x480_422i_SP_5Mbps_30fps_657frames.yuv)  
> but when i checked the location([//192.122.227.53/Smar/streams2](https://192.122.227.53/Smar/streams2)) file was  
> there  
> what could be the reason ??

I have no idea where are you receiving the ‘invalid argument’ error.

It is extrematelly important than when you report an error, provide  
enough details and precision about it, more precisely, the full error  
messages and backtraces.

We can’t replicate or provide you help if you skim it and provide  
vague information.

## Help us help you.

## Luis L. AREA 17

Perfection in design is achieved not when there is nothing more to add,  
but rather when there is nothing more to take away.  
Antoine de Saint-Exupéry
