# Failed to map segment from shared object: Operation not permitted

**URL:** <https://www.ruby-forum.com/t/failed-to-map-segment-from-shared-object-operation-not-permitted/142176>\
**Category:** Ruby\
**Created:** [July 4, 2008, 5:54am UTC](https://www.ruby-forum.com/t/failed-to-map-segment-from-shared-object-operation-not-permitted/142176 "2008-07-04T05:54:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tristincolby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/58f4c7/32.png) [@tristincolby](https://www.ruby-forum.com/u/tristincolby)\
**Post date:** [July 4, 2008, 5:54am UTC](https://www.ruby-forum.com/t/failed-to-map-segment-from-shared-object-operation-not-permitted/142176/1 "2008-07-04T05:54:40Z")

</div>

I’m writing a ruby wrapper for a proprietary api. I compiled it, but  
when I  
require it in irb i get the following error. I’m stumped as to why its  
throwing this error. Anyone help?

irb(main):001:0\> require ‘metadata’  
LoadError: ./metadata.so: failed to map segment from shared object:  
Operation not permitted - ./metadata.so  
from ./metadata.so  
from (irb):1

=cut

#include \<ruby.h\>  
#include “mdc.h”

/\* Module and class names \*/  
static VALUE md\_mMetadata;  
static VALUE md\_cClientAPI;

VALUE  
md\_initialize(int argc, VALUE \*argv, VALUE self)  
{  
VALUE login, password, server, table\_name, table\_version;

```
  rb_scan_args(argc, argv, "41", &login, &password, &server,

```

&table\_name, &table\_version);

```
  if(NIL_P(table_version)) {
    rb_iv_set( self, "@table_version", Qnil );
  }

  rb_iv_set(self, "@login", rb_funcall(login, rb_intern("to_s"), 0) 

```

);  
rb\_iv\_set(self, “@password”, rb\_funcall(password,  
rb\_intern(“to\_s”),  
0) );  
rb\_iv\_set(self, “@server”, rb\_funcall(server, rb\_intern(“to\_s”),  
0) );

```
  rb_iv_set(self, "@table_name", rb_funcall(table_name,

```

rb\_intern(“to\_s”),0) );

```
  return self;

```

}

void Init\_metadata() {  
md\_mMetadata = rb\_define\_module(“Metadata”);  
md\_cClientAPI = rb\_define\_class\_under(md\_mMetadata, “ClientAPI”,  
rb\_cObject);

rb\_define\_method(md\_cClientAPI, “initialize”, md\_initialize, 4);

}

---

<div class="post-metadata">

**Author:** ![tristincolby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/58f4c7/32.png) [@tristincolby](https://www.ruby-forum.com/u/tristincolby)\
**Post date:** [July 4, 2008, 6:05am UTC](https://www.ruby-forum.com/t/failed-to-map-segment-from-shared-object-operation-not-permitted/142176/2 "2008-07-04T06:05:12Z")

</div>

On Jul 3, 2008, at 9:46 PM, Tristin D. wrote:

> from (irb):1  
> Are you compiling the code as one user and attempting to use it from a  
> different user account? The “Operation not permitted” usually refers  
> to a permissions problem.

Found this link …

\<[http://citydesknews.com/FogBugz/KB/errors/fogutil.sofailedtomapsegm.html?isl=23903](http://citydesknews.com/FogBugz/KB/errors/fogutil.sofailedtomapsegm.html?isl=23903)

> 

Give the “restorecon” method a shot.

Oh, and this link might shed some light as well …

\<[http://objectmix.com/tcl/34666-failed-map-segment-shared-object-operation-not-permitted.html](http://objectmix.com/tcl/34666-failed-map-segment-shared-object-operation-not-permitted.html)

> 

Blessings,  
TwP

---

<div class="post-metadata">

**Author:** ![tristincolby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/58f4c7/32.png) [@tristincolby](https://www.ruby-forum.com/u/tristincolby)\
**Post date:** [July 4, 2008, 7:21am UTC](https://www.ruby-forum.com/t/failed-to-map-segment-from-shared-object-operation-not-permitted/142176/3 "2008-07-04T07:21:47Z")

</div>

I tried it the solution in the 1st link, but it didn’t help.

---

<div class="post-metadata">

**Author:** ![tristincolby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/58f4c7/32.png) [@tristincolby](https://www.ruby-forum.com/u/tristincolby)\
**Post date:** [July 4, 2008, 9:12pm UTC](https://www.ruby-forum.com/t/failed-to-map-segment-from-shared-object-operation-not-permitted/142176/4 "2008-07-04T21:12:07Z")

</div>

Nevermind, I figured it out. I’m running working off of a flash drive  
and I  
guess by default, Ubuntu mounts it with the noexec option.

/dev/sdb1 on /media/ext type vfat (rw,noexec,nosuid,nodev)

Moving it to another directory fixed it.

On Fri, Jul 4, 2008 at 1:55 PM, Tristin D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![tristincolby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/58f4c7/32.png) [@tristincolby](https://www.ruby-forum.com/u/tristincolby)\
**Post date:** [July 4, 2008, 8:59pm UTC](https://www.ruby-forum.com/t/failed-to-map-segment-from-shared-object-operation-not-permitted/142176/5 "2008-07-04T20:59:42Z")

</div>

I"m on Ubuntu 4.2.3-2ubuntu7.

Anyone else have any suggestions. I’ve checked and rechecked the code.  
I  
can’t find anything wrong at all.

On Fri, Jul 4, 2008 at 12:17 AM, Tristin D. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
